OnDisconnect

Options
Sergiy
Sergiy
edited May 2012 in Photon Server
Hi

Previous version of my server was using classes that were derived from PeerBase. In new version peers are derived from Peer and are using IOperationHandler interface.

When deriving from PeerBase I had DisconnectReason in OnDisconnect() event. IOperationHandler does have its own OnDisconnect() event, but without DisconnectReason parameter.

Questions:
1. Can I get somehow this variable's value?
2. If I implement both OnDisconnect() methods - which one will fire first? Can you suggest some pattern, what to do in this situation?

Thanks

Comments

  • Philip
    Options
    From what you explain it's not completely clear what you are doing.

    But i'll assume you are inheriting from RPC.Peer - where the code is:
    protected override void OnDisconnect(DisconnectReason reasonCode, string reasonDetail)
            {
                this.CurrentOperationHandler.OnDisconnect(this);
            }
    

    which you can override to get the reason code.
  • Sergiy
    Options
    Thanks for answer, Philip

    You are right, I'm inheriting from RPC.Peer. so my class header looks like
    public class TestPeer: Peer, IOperationHandler
    
    so I have two different OnDisconnect() events:
    1. OnDisconnect(Peer peer) - inherited from IOperationHandler
    2. OnDisconnect(DisconnectReason reasonCode, string reasonDetail) - inherited from RPC.Peer

    Which one should I override to implement custom behavior?

    From your answer I suggest that overriding either one of them gives the same result. However it's preferable (for me) to override OnDisconnect(DisconnectReason reasonCode, string reasonDetail) to get reasonCode. is it correct?
  • Philip
    Options
    yes