OnDisconnect
Options
Sergiy
✭
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
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
0
Comments
-
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.0 -
Thanks for answer, Philip
You are right, I'm inheriting from RPC.Peer. so my class header looks likepublic 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?0 -
yes0