Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

order of execution of buffered RPC

Discussion in 'Multiplayer' started by llavigne, Mar 17, 2008.

  1. llavigne

    llavigne

    Joined:
    Dec 27, 2007
    Posts:
    977
    When a new player joins in, the other players are instantiated automatically because network.instantiate was used.

    On each of these other players, the history of their game, the pickups they got, how many hitpoints they lost etc... are all handled by RPC calls which happened during the game under RPCMode.AllBuffered

    1- if say 200 events were buffered, is it slow to be transfered (considering serializing here)

    2- what's the order of execution of these buffered RPCs that are being called before the game starts playing on the new player's computer, do they executed before or after the Start() of each script of the other players?
     
  2. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,306
    In TRaceON, I originally used buffered RPCs for the team configuration. Each time a player created or removed, joined or left a team, a buffered RPC was sent. When I had about 10 or so changes, that already looked kind of funny in the GUI (all on my local network), so I would guess that having 200 buffered RPCs will take a moment. Probably, it won't be particularly long (just a few seconds), but it might already give you some funny effects, if not handled properly.

    Since I found the handling of the buffered RPCs a bit awkward for my purposes, I completely removed it and now keep the state on the server and only send the current state to the client (instead of including all the history since the first player logged in).

    I guess if the server sends an RPC to the client on connect saying "done", and not showing anything of the game before that should make it look fine, though... As the order of RPCs is guaranteed, you can rely on this RPC coming in after all the buffered stuff, so this should work just fine.

    The calls are guaranteed to be sent in the order they were created. However, I don't think there's any guarantees on how they are received on the client for obvious reasons. The order is guaranteed (i.e. RPC 1 will come in after RPC 2, if 1 was sent before 2), but not when they are received. I don't know when the first one might come in - but I'm sure some might be "dripping in late".

    However, it might be that the RPCs are handled somewhere in the Update-Loop which might imply that they are at least guaranteed to be received after Start(). But I don't know more about that... One thing I've been wondering about for quite some time is where exactly the RPCs are handled. That would also answer your question ;-)

    It would be nice to maybe add this information to:

    http://www.unifycommunity.com/wiki/index.php?title=Event_Execution_Order

    Sunny regards,
    Jashan