Message on disconnect?

Hello!

I'm using Photon Self-Hosted and had a question. When I disconnect a peer, is there a way to send a message to that client about why they are being disconnected? Failing that, is there a good way to make sure we've flushed a specific Event or Object and that the client has received it?

I'm seeing that if I send an Event or Object over, they may not get there until the disconnect happens, and sometimes won't get there at all. I have tried calling Flush() but that doesn't seem to make a difference. If I send the payload, then wait a half second, then disconnect, that seems to work, but even that can be unreliable depending on latency.

Thanks!

Comments

  • hi, @corwinlw

    the way you found is the only way, but you should wait more 3-5 seconds is ok. also, you need to raise up flag in Peer that after calling method SendEventAndDisconnect it does not bother you with any incomming data.

    also you may add reaction on client: so that when it gets this message it disconnects from server

    best,
    ilya
  • Thanks! Where is the method "SendEventAndDisconnect" located? Also what flag do I need to raise on the Peer?
  • @chvetsov I don't know if I have to tag you for you to see my response, so I'm doing it now. Thanks!
  • chvetsovchvetsov mod
    edited March 28
    you should do it your self
    it will look like this.
    
    SendResult SendEventAndDisconnect(IEventData data, SendParameters paramters, int disconnectDelay = 3000)
    {
       this.ScheduleForDisconnect = true;
       var result = this.SendEvent(data, parameters);
       this.RequestFiber.Schedule(this.Disconnect, disconnectDelay);
    }
    
    use this.ScheduleForDisconnect to reject all incoming operation requests

    best,
    ilya
Sign In or Register to comment.