Using RPCs With Operations

Hey all,

Is it possible to call both RPCs to other users and Operations to the Photon server within a single Unity application? If so, how would I go about initiating an Operation?
I'm sorry if this has been asked before, it's just quite confusing to me

Comments

  • Is it possible to call both RPCs to other users and Operations to the Photon server within a single Unity application?
    If you are talking about the client-side, it certainly is. Have a read of this comment here to see how to use operations, and events (events are a tool that you should be thinking about too): forum.photonengine.com/discussion/comment/25439/#Comment_25439

    I would suggest to work your way through the tutorials on the Photon Server documentation, as these will clue you up on how to set up the client-side code for sending operations/events to a Photon server. Once you get to this point, you should have a basic understanding of how to handle operations and events from both the client and server side.


    The next part to understand is RPCs. An RPC (remote procedure call) is a common thing in networking, the idea being that you remotely call a procedure (function/method) on an object that exists on the network. The tricky part of an RPC is being able to target a networked object as the object that you want to call the procedure on. This is something that you should be able to work out for yourself and would be a little too complex to explain in a forum post, so i'll simply give you some pointers to get you started:
    - An RPC is not a photon-specific term. Read up on it here: https://en.wikipedia.org/wiki/Remote_procedure_call
    - The source code of PUN is a good place to start to get an idea of how to handle RPCs from the client-side. PUN's PhotonView component handles a lot of the work for you and acts as a "networked object" that can act as your target object to an RPC
    - The Lite application that comes built into the Photon Server SDK (within the src-server folder) contains functionality for handling RPCs on the server-side, so this would be a good place to look to see how to handle this on the server.

    I hope this helps.
  • @donnysobonny: Great answer, thanks!
    Actually, for Photon, Operations are RPCs that the client can do on the server. It tells the server to do something and they get a OperationResponse. Aside from that, Photon's events are just a category of messages that the client receives anytime (without triggering those). RaiseEvent is an operation/rpc to make the server send those.
  • Ah, that makes it very clear.
    Thank you so much for the detailed response, I really appreciate it