Informing all clients about one client's disconnection

edited August 2010 in Photon Server
Hi,

I've built a small global chat class with its own MessageChannel with all clients subscribing by entering the world (based on MmoDemo). Message transferring between clients works great, but now I'm trying to include some system/server messaging. I can see the message about client connected after entering the world (and after chat subscription) - that was easy, however I don't have a clue where to put the call when the client is disconnecting. MmoPeer class has a method onDisconnect and I believe it's the main method called by client disconnection. However, all is immediately disposed, so I can't send the message about the disconnection to all other clients.

How can I stop the client disconnection until I inform all other clients about this disconnection? I can see a method MmoPeer.ResponseQueue.EnqueueAction in MmoPeer.OnDisconnectByOtherPeer but I have no idea how to use it.. Also remembering the fact that I use a different channel for text messaging.

Comments

  • The peer itself is disposed, but not your chat channel.
    You can publish a message into that channel at OnDisconnect.
    Note that not only the MmoPeer has the OnDisconnect member, there is also the MmoActor. It's part of the IOperationHandler interface.
    I might be able to give more advice if you posted some code.
  • Oh my.. Right, I was calling my message in MmoPeer.onDisconnect where MmoActor is already disposed and I was referring to its properties ;) Now I moved the call to MmoActor.onDisconnect before disposing and all is working great. Thanks!
Sign In or Register to comment.