Hi everyone I need help with detecting client disconnect event.I made custom client behavior and apply it to the client.Client and service have duplex com. via NetNamedPipe and now I want to catch event when client just terminate application(call some methos on service side).I have implent IChannelInitializer:
public void Initialize(IClientChannel channel)
{
channel.Opened+=new EventHandler(channel_Opened);
channel.Closed+=new EventHandler(channel_Closed);
channel.Faulted+=new EventHandler(channel_Faulted);
channel.Closing+=new EventHandler(channel_Closing);
}
public void channel_Opened(object sender, EventArgs e)
{
ClientIntruder.Instance.StopMeasure();
}
public void channel_Closed(object sender, EventArgs e)
{
ClientIntruder.Instance.StopMeasure();
}
public void channel_Faulted(object sender, EventArgs e)
{
ClientIntruder.Instance.StopMeasure();
}
public void channel_Closing(object sender, EventArgs e)
{
ClientIntruder.Instance.StopMeasure();
}
and attach it throw:clientRuntime.ChannelInitializers.Add(ClientIntruder.Instance) in EndpointBehavior.On channel_Opened method works but other methods don't work.What should I do?????
PLEASE HELP
THANKS IN ADVANCE
Loading
Danatas GerviPosted Aug 16, 2009, 5:10 AM
channel.Closed+=new EventHandler(channel_Closed);
channel.Faulted+=new EventHandler(channel_Faulted);
channel.Closing+=new EventHandler(channel_Closing);
will happens if channel closes on server side.
There is no way to know (in TCP/IP network) that client is disconnected - exept timeout.
Or your should implement your own messages protocol over WCF -
for example - call from client every 3 second something "I am connected" function.
Or - Client before its application exit should warn the server - "I am closing the connect".
I mean, TCP connection - this is not "channel" - Client know adress+port to send TCP packet - Server is waiting on this adress+port.
If nofhing was sent, both - client and server can know only "nothing was sent 40 seconds - seems nothing will be - better to close the "channel" by timeout"
:)
suryaji shindePosted May 19, 2015, 9:21 AM
mark draganPosted Aug 16, 2009, 8:13 AM