https://github.com/cacilhas/lrpc
A spartan example of RPC over UDP, powered by MoonScript and LuaJIT.
https://github.com/cacilhas/lrpc
luajit moonscript poc rpc
Last synced: 6 months ago
JSON representation
A spartan example of RPC over UDP, powered by MoonScript and LuaJIT.
- Host: GitHub
- URL: https://github.com/cacilhas/lrpc
- Owner: cacilhas
- License: other
- Created: 2019-01-07T22:14:36.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-07T23:31:32.000Z (about 7 years ago)
- Last Synced: 2025-03-14T23:26:26.453Z (11 months ago)
- Topics: luajit, moonscript, poc, rpc
- Language: MoonScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# LRPC
A spartan example of RPC over UDP, powered by
[MoonScript](http://moonscript.org/) and [LuaJIT](http://luajit.org).
## Dependencies
LRPC requires [LuaSocket](http://w3.impa.br/~diego/software/luasocket/). Be
careful when compiling it, remember to use LuaJIT headers and libs instead of
traditional Lua.
Indeed, in the current release, LRPC shall work over traditional Lua, but it’s
not tested.
I’ve opted for LuaSocket so LRPC can be used in [LÖVE](https://love2d.org/).
## Installing
```
#!bash
make
make test
sudo make install
```
## Use
### The server
```
#!moonscript
Server = assert require "lrpc.server"
server = Server!
server.callbacks.add = (a, b) -> a + b
server\serve!
```
The `Server` constructor accepts two parameters:
* The first is the IP to listen, defaults to `"*"`;
* The second is the port, defaults to `54000`.
Note: use `coroutine.yield` on callback’s loops to release server for handling
other connections.
### The client
```
#!moonscript
Client = assert require "lrpc.client"
client = (Client "localhost").remote
print client.add 2, 3
```
The `Client` constructor accepts two parameters:
* The first is the host to connect, no default value;
* The second is the port, defaults to `54000`.
## Author
[ℜodrigo Arĥimedeς ℳontegasppa ℭacilhας](mailto:batalema@cacilhas.info)