Calling custom server operations from Unity

Options
So I've been going through the Server documentation and setting up some custom operations, but I haven't seen anything in the docs on how to call these using the Unity plugin. It looks like I need access to the NetworkingPeer to call OpCustom(), and after some exploring I found that the networkingPeer is located in PhotonNetwork, but it is internal. Should I just change it from internal to public, or is there a more standard way of calling custom operations that I just haven't noticed?

Also, I haven't yet considered how I will receive operation responses, would that require more hacking to set up my own callbacks?

Thanks!
Scott W

Comments

  • SamusAranX
    Options
    Ah, it looks like half of the Photon Unity library is mine to mess with, so I'm guessing I'm supposed to implement these features internally, correct?

    Edit: So I got both the client and the server communicating correctly. It was difficult getting it to work because I couldn't tell if my server was actually updating correctly when I re-published it to Azure (nor when I ran it locally). I also couldn't be sure if it was deploying correctly and my code was just wrong.
  • How did you manage to get the operation response working? From what i gather you can set the externalListener field to public and use it outside... I'm gonna give that a try and see how it goes.
  • SamusAranX
    Options
    I added custom response handling in NetworkingPeer.cs, although it technically isn't a public API. I can go into more detail later in the week, but I'll be pretty busy for the next couple of days.
  • Tobias
    Options
    Yes, we opened PUN so you can mess with it. Then we got scared and made stuff internal, so it's clear you don't want to use it unless you are OK with messing with PUN.
    If that makes sense.

    Basically, PUN wraps a lot of the basic API and makes a lot of that static (which was Unity's way of implementing an easy networking API). Make the networkingpeer public and modify OnOperationResponse to forward you anything it doesn't know.
    In best case, you keep modifications of the actual files low and work with extending them. This makes it easier to update to newer PUN versions later on.

    Aside from that, you're on the right track.
    Sorry for my really late reply, btw.