RPC Library? help-me

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
marcosmfilho
Prole
Posts: 6
Joined: Mon May 01, 2017 3:10 pm

RPC Library? help-me

Post by marcosmfilho » Fri May 12, 2017 12:51 pm

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.

User avatar
zorg
Party member
Posts: 3044
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: RPC Library? help-me

Post by zorg » 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.
Me and my stuff :3True 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.

marcosmfilho
Prole
Posts: 6
Joined: Mon May 01, 2017 3:10 pm

Re: RPC Library? help-me

Post by marcosmfilho » Fri May 12, 2017 1:47 pm

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.
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.

User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: RPC Library? help-me

Post by raidho36 » Fri May 12, 2017 7:06 pm

Remote calls work over sockets. I don't know what's your problem with it.

MasterLee
Party member
Posts: 141
Joined: Tue Mar 07, 2017 4:03 pm
Contact:

Re: RPC Library? help-me

Post by MasterLee » Sat May 13, 2017 6:28 pm

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.

User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: RPC Library? help-me

Post by airstruck » 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.

marcosmfilho
Prole
Posts: 6
Joined: Mon May 01, 2017 3:10 pm

Re: RPC Library? help-me

Post by marcosmfilho » Sun May 21, 2017 12:56 pm

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?

User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: RPC Library? help-me

Post by airstruck » 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).

marcosmfilho
Prole
Posts: 6
Joined: Mon May 01, 2017 3:10 pm

Re: RPC Library? help-me

Post by marcosmfilho » Sun May 21, 2017 9:19 pm

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).
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.

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.

marcosmfilho
Prole
Posts: 6
Joined: Mon May 01, 2017 3:10 pm

Re: RPC Library? help-me

Post by marcosmfilho » Sun May 21, 2017 9:47 pm

marcosmfilho wrote:
Sun May 21, 2017 9:19 pm
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).
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.

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.
For example:
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 :(

Post Reply

Who is online

Users browsing this forum: Gunroar:Cannon() and 55 guests