Method to pause outgoing messages? Or method to tell client to set isMessageQueueRunning to true?

Hello, I'm having an issue with players joining a game and while they're awaiting the MasterClient to initialize the scene and then send the the fully loaded game state, the MasterClient sends some intermediary RPCs, which the joining client doesn't exactly know how to handle, because they haven't received the full game state yet. Specifically, in a number of my intialization methods, a lot of network objects send messages over the network.

I realize I could check in each of those RPC calls if it's coming from the MasterClient and then check if the MasterClient has 'finishedLoadingLevel', but I'm I'm realizing this late and that's a lot of methods I'm going to have to find and I would prefer to not have that check in every function that sends a network message. I realize I can toggle off PhotonNetwork.isMessageQueueRunning for the joining player, but then I don't know how to tell that player to turn the queue back once the MasterClient is done setting up the level. If there were something that I could toggle on the MasterClient like PhotonNetwork.isSendingMesssages, then I could toggle that off, initialize the level, toggle it on, then send the game state out to any other players in the room waiting for the game state.

Thanks for reading :)

Answers

  • Hi @maxclark,

    Thank you for choosing Photon!

    For PUN1, did you read "Switching Scenes" and "Timing For RPCs And Loading Levels"?
  • So I use automaticallySyncScene set to true and I have just the master client call PhotonNetwork.LoadLevel (). And I understand the message queue. Or at least I think I do understand these things. Here’s the sequence of events:

    ——————————

    Master and clients are having a good time in level1.

    End of level is reached, master saves relevant game state info to a scriptable object.

    Master PhotonNetwork destroys everything and calls LoadLevel (with syncscene enabled).

    In new scene, In my level manager start function, the master generates a new level and uses the game state info to initialize everything.

    This is where some objects start sending RPCs that are interdependent on the whole game state and that I’m now blocking their being sent out with a multitude of little logic checks

    Master saves the new gamestate and sends that to any clients.

    —————————————

    As I understand it, turning off the message queue just let’s the local photon player ignore incoming messages. So if all the clients were to have their message queues not running, yes, they wouldn’t receive those RPCs that would confuse them, but how would they know when to reactivate the message queue so that they can receive the Rpc with the whole game state.

    Let me know if my situation is unclear or if I’m misunderstanding anything. And thanks for the response.
  • JohnTubeJohnTube mod
    edited August 15
    Hi @maxclark,

    Sorry for the delay!

    how would they know when to reactivate the message queue so that they can receive the Rpc with the whole game state.
    You reenable the message queue when the client is ready to process incoming messages. Usually, the common use case for pausing the message queue is scene loading. So when the scene finishes loading, the message queue is reenabled.
Sign In or Register to comment.