Closing the game or losing Connection message?

Options
Baenor
Baenor
Hi guys, i was making a message to appear in the chat if a players Join or Leaves the Room...and everything works fine.

But if i close the game with non canonical ways, no message "Player left the room" appears in the chat.
How can i handle this situation?

I'm using Photon Cloud right now and i dont know how can i send a message to other players connected if someone leaves the game by shutting down the pc, or connection, or the game with non canonical ways....
Can you help me?

Comments

  • Usually, it sends a message for me no matter how the connection closed.
  • vadim
    Options
    Hi,

    How do you get "Player left the room" message? Do you print it on OnPhotonPlayerDisconnected handler?
    It may take more than 10 seconds for server to find out that client is disconnected w/o sending 'leave' event.
  • Baenor
    Options
    At the moment i use an RPC that is inside the player...if he hits "Leave the Game" button the RPC is called...The RPC just get my Chat Gameobject and instantiate inside a ChatMessage gameobject....

    The fact is that i dont know how to send messages to everyone without calling RPC on players......can you tell me how to do that? Because i know that the issue is this!

    I was reading of on Sending Events, and RaiseEvent function...is maybe this?
  • vadim
    Options
    Usually PhotonNetwork.LeaveRoom() called on "Leave the Game" button hit. In that case OnPhotonPlayerDisconnected will be called on all other clients. Just handle this message.
  • Tobias
    Options
    Mobile clients will usually not allow your game any CPU time in the background. Due to that, also network connections fail and after ~10 seconds, the server will timeout the connection. This is the moment when remaining players get an event and PUN will call the callback: OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer).

    In Photon Chat (different API), there is no such update if someone leaves.
    You can add "Friends" to your server list, if you're really interested in their online state. This will give you updates of friends.