Good morning, I'm doing a distributed systems discipline in college ...
The first exercise was to create a multiplayer game with sockets. It was easy.
My problem is in the second exercise, I need to change the game technology to rpc (remote procedure call), something similar to the Java RMI.
Is there any library that will help me to implement rpc (in Lua)?
I'm using love2d.
RPC Library? help-me
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: RPC Library? help-me
RPC is a pretty generic technology though; but i'm guessing you need to have a server which gets requests to call procedures, and then return the results to the client(s)?
you can just send 1+n messages, first the function name, then the parameters that the function expects, and it will return the results to you...
though you might need to create something more specialized, you didn't specify.
you can just send 1+n messages, first the function name, then the parameters that the function expects, and it will return the results to you...
though you might need to create something more specialized, you didn't specify.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
-
- Prole
- Posts: 6
- Joined: Mon May 01, 2017 3:10 pm
Re: RPC Library? help-me
That's exactly what I need. I need to move a part by calling a server's "movePiece" method for example and the piece's position is updated on all other clients. Only with remote calls, without using sockets explicitly. Something similar to JAVA RMI.zorg wrote: ↑Fri May 12, 2017 1:37 pm RPC is a pretty generic technology though; but i'm guessing you need to have a server which gets requests to call procedures, and then return the results to the client(s)?
you can just send 1+n messages, first the function name, then the parameters that the function expects, and it will return the results to you...
though you might need to create something more specialized, you didn't specify.
Re: RPC Library? help-me
Remote calls work over sockets. I don't know what's your problem with it.
Re: RPC Library? help-me
The Problem is easy when communicating with other systems there should be an standard. It should be documented how to make RPC call or how to process them, so that both the client or server could be changed.
SOAP for example is an standard that could be used for that.
Luckily nobody has to learn SOAP to use it as most languages have subsystems (e.g. modules, libraries etc.) to handle all aspects off SOAP Stuff.
But visit http://ladonize.org/ there are some examples for Python, PHP and Javascript. You may also find some JSON-WSP which is an alternative to SOAP, but it maybe not supported by any Lua module.
SOAP for example is an standard that could be used for that.
Luckily nobody has to learn SOAP to use it as most languages have subsystems (e.g. modules, libraries etc.) to handle all aspects off SOAP Stuff.
But visit http://ladonize.org/ there are some examples for Python, PHP and Javascript. You may also find some JSON-WSP which is an alternative to SOAP, but it maybe not supported by any Lua module.
Re: RPC Library? help-me
I took a crack at it.
https://gist.github.com/airstruck/5e0d0 ... 4afe6e75dc
Uses binser for serialization. Should be pretty straightforward, see examples. Everything is synchronous. Define your remote procs as methods of the rpc server object (as rpc:method, not rpc.function), and then call them as methods of the rpc client object. Magic!
Probably too brittle for anything serious, but should be fine for a school project.
https://gist.github.com/airstruck/5e0d0 ... 4afe6e75dc
Uses binser for serialization. Should be pretty straightforward, see examples. Everything is synchronous. Define your remote procs as methods of the rpc server object (as rpc:method, not rpc.function), and then call them as methods of the rpc client object. Magic!
Probably too brittle for anything serious, but should be fine for a school project.
-
- Prole
- Posts: 6
- Joined: Mon May 01, 2017 3:10 pm
Re: RPC Library? help-me
airstruck wrote: ↑Sun May 14, 2017 6:22 pm I took a crack at it.
https://gist.github.com/airstruck/5e0d0 ... 4afe6e75dc
Uses binser for serialization. Should be pretty straightforward, see examples. Everything is synchronous. Define your remote procs as methods of the rpc server object (as rpc:method, not rpc.function), and then call them as methods of the rpc client object. Magic!
Probably too brittle for anything serious, but should be fine for a school project.
Perfect, besides functions, can I access variables and objects remotely?
Re: RPC Library? help-me
Not directly, but you can write getter and setter RPC methods instead. This way you can make sure a client has permission to change or view data based on whatever rules you want. The only reason I went for "methods" rather than "functions" is so you have access to the relevant sockets via self (so you can determine connected client's IP, for example).
-
- Prole
- Posts: 6
- Joined: Mon May 01, 2017 3:10 pm
Re: RPC Library? help-me
I have a problem with this rpc library that you showed me. I can not put generic ports for clients, the client port has to be the same as the server port to work, so I can not differentiate the clients.airstruck wrote: ↑Sun May 21, 2017 8:19 pm Not directly, but you can write getter and setter RPC methods instead. This way you can make sure a client has permission to change or view data based on whatever rules you want. The only reason I went for "methods" rather than "functions" is so you have access to the relevant sockets via self (so you can determine connected client's IP, for example).
For example, how would you do a chat using this RPC implementation between two clients and a server? (Remembering that I can not use sockets explicitly, by teacher's requirement, only remote calls, which obviously use sockets behind)
Can you help me? First of all, I want to thank you for your help.
-
- Prole
- Posts: 6
- Joined: Mon May 01, 2017 3:10 pm
Re: RPC Library? help-me
For example:marcosmfilho wrote: ↑Sun May 21, 2017 9:19 pmI have a problem with this rpc library that you showed me. I can not put generic ports for clients, the client port has to be the same as the server port to work, so I can not differentiate the clients.airstruck wrote: ↑Sun May 21, 2017 8:19 pm Not directly, but you can write getter and setter RPC methods instead. This way you can make sure a client has permission to change or view data based on whatever rules you want. The only reason I went for "methods" rather than "functions" is so you have access to the relevant sockets via self (so you can determine connected client's IP, for example).
For example, how would you do a chat using this RPC implementation between two clients and a server? (Remembering that I can not use sockets explicitly, by teacher's requirement, only remote calls, which obviously use sockets behind)
Can you help me? First of all, I want to thank you for your help.
In server:
function newMessage(nameuser, message)
return nameuser .. ': ' .. message
end
Client 1:
rpc:newMessage('client1', 'hello client2')
Client 2 (The message should arrive instantaneously on client 2 without it having to make any calls):
client1 says: 'hello client2'
How can I do this with RPC only? Help me out
Who is online
Users browsing this forum: Bing [Bot] and 2 guests