Photon RPC
Can someone explain to me what the point of a Photon RPC is? I had the understanding that an RPC was meant for calling a method or function on the server so that it will carry out the action. But after reading the Photon RPC API, I’m even more confused than when I started..
So far all that I have seen are examples of the method and the RPC being in the same script so that it synchronizes all clients in the room. But how does that protect the script from client side edits in anyway? How Can I separate the client side interactions from the server side logic?
All I would like to do is set up my Photon Server with my custom logic to be run, but I can’t for the life of me figure out how to call these methods that I want the server to run when the client initiates them and then send that action back to all clients to be synchronized.
Essentially, I want a setup where Client clicks a button. When the button is clicked, it tells the server “this button was clicked run ButtonClicked();”
Then the server acknowledges the clients request, runs the method on the server side (to protect it from client side code editing), then sends that action back to all clients where they update their “version” of the game on their local device
Answer by ChristianSimon · Nov 09, 2017 at 01:13 PM
Hi,
a RPC is a Remote Procedure Call which is executed on all clients the RPC is sent to. The server itself doesn't process the RPC, it furthermore just forwards the message to all necessary clients. If you haven't done this already, I would like recommend you reading the RPCs and RaiseEvent documentation page, which gives you the idea, how RPCs work and what they are actually used for.
You have told us, that you already planned running your own server in order to have custom server-side logic. Custom server-side logic can either be added by implementing your own server application based on Photon or implement a plugin which can be used either with the Photon Enterprise Cloud or with any existing Photon Server application.
To achieve the above described scenario, you can either send an operation to the server or raise an event. Server-side operations are described here, adding server-side events works basically the same way.
Please let me know, if you have further questions.
Answer by abentley · Nov 11, 2017 at 07:19 AM
Thank you!! This is perfect! Now maybe I’ll finally be able to create a multiplayer iOS app