mark dragan

mark dragan

  • NA
  • 38
  • 0

WCF client disconnect event

Aug 13 2009 10:51 PM

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

Answers (3)