RPC vs RPC via server.

Options
Hello, I've read the documentation, even look into Photon code, but this topic is still not 100% clear :).

So when we call an RPC using a none server target (so using any except AllViaServer and AllBufferedViaServer), this network communication will not reach the server is that correct? If so, this means the clients are connected Peer-To-Peer? What is the network protocol handling this, is it UDP or TCP? For servers target, it seems clear it reach the server correct?

Don T.

Comments

  • Tobias
    Options
    Ignore the server for PUN. The server does not exist in the PUN client side. It is transparent and just forwards events from one client to the others and does some caching of events.
    You always communicate through the server but it's not visible for the clients.

    All clients are equal. The Master Client is selected as "the player with the lowest ID" and not really special. It just takes control of the GameObjects no one else controls.

    What is a server target?
  • dontonka
    Options
    Ok thanks Toblas.
    What is a server target?
    I was referring to AllViaServer and AllBufferedViaServer. So what is the difference beetween AllViaServer and All target when using PUN (I'm referring to the enum PhotonTargets)?

    Cheers,
    Don T.
  • Tobias
    Options
    The difference between AllViaServer and All target is the path that the RPC takes for the local player.
    With "All", PUN sends the RPC to the others and executes it locally. This saves the roundtrip and some traffic but the execution order is different locally than for everyone else.
    With "AllViaServer", PUN asks the server to send the RPC to everyone, including "this" client. PUN does not use a shortcut and execution of the RPC is in the same order as on other clients.
  • MrVentures
    Options
    Hey @Tobias I am curious why the asteroids example would use this line:

    photonView.RPC("Fire", RpcTarget.AllViaServer, rigidbody.position, rigidbody.rotation);

    Wouldn't we want to use RpcTarget.All in this case, since a round trip delay every time the player fires would be noticeable? You mentioned "the execution order is different locally than for everyone else", what is the risk associated with this if I were to say... replace the above line with RpcTarget.All?
  • Tobias
    Options
    Yes, the lag could be noticed easily. The Asteroids demo doesn't solve shooting very .. precise.
    The assumption is that you get about the same timing for everyone, if all players (including the shooter) fire on receiving the event.
    You could / should add a local prediction of what's going on: Fire a shot immediately and move it accordingly. Then you have to align / correct your local prediction, when the event arrives.
    If each player does this properly, the results are the same on all clients.
  • IBX00
    Options

    @Tobias

    Sorry to ask on this old thread but can you please elaborate on this part of your answer:

    "the execution order is different locally than for everyone else"

    What order of execution are we talking about?

    Let's take my example for now.

    Suppose we have a room with 3 players: A, B, and C.

    "A" fires an RPC on its own photon view. What order are we talking about then? Is it the order in which B and C will receive the RPC? And how will it be different in these two cases(RpcTarget.All vs RpcTarget.AllViaServer)? I know that in the case of RpcTartget. All, the execution will be immediate on whomsoever fires the Rpc.


    Sorry if it sounds like a dumb question but I solved an irritating bug by just changing the Target from All to AllViaServer and I'm simply unaware of why it worked.

  • Tobias
    Options

    Sorry for the late reply.

    When you use Target.All, the client on which you call the RPC will send it and immediately execute it locally. Meaning the others will execute it after a full roundtrip time while the local client already changed state.

    When you use Target.AllViaServer, the RPC will be sent to all clients, including the one that called the RPC locally. All clients in the room get the RPC via event and also the local one will wait the roundtrip before executing the actual RPC it called.

    Makes more sense?