Hi Jonny,
I've seen your new thread and posted my reply there. Here is my reply
content for your convenience:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Hi Jonny,
Thanks for your followup.
Also sorry for the late reponse as I was dealing with some other issues
recently. Regarding on the detecting client-side disconnecting problem,
I've also performed some further research. It seems for normal one-way
binding(comparing to thte duplex binding), the client-side disconnect
detection is not real-time. Here are some web articles discussing on this
issue:
#WCF Notification on Disconnect
http://www.rcs-solutions.com/blog/20...Disconnect.asp
x
#Taking Action on Client Close
http://blogs.msdn.com/drnick/archive...on-client-clos
e.aspx
#Provide Way to Detect Client Abort/Disconnect in WCF
http://social.msdn.microsoft.com/For...e30-fc74-4a52-
9dfd-232c67c84f7a
I've tried registering some eventhandler on the OperationContext's Channel,
but those event won't be raised until the service method return data to
client-side. e.g,
========================
public string GetData(string user)
{
Console.WriteLine("GetData Begin:{0}", DateTime.Now);
OperationContext oc = OperationContext.Current;
oc.Channel.Closed += new EventHandler(Channel_Closed);
oc.Channel.Closing += new EventHandler(Channel_Closing);
oc.Channel.Faulted += new EventHandler(Channel_Faulted);
for (int i = 0; i < 10; ++i)
{
Console.WriteLine("Loop:{0}, State:{1}",i,
oc.Channel.State);
Thread.Sleep(1000 * 3);
}
Console.WriteLine("GetData End:{0}", DateTime.Now);
return "result of " + user;
}
===============================
If duplex binding is possible for your scenario, you may have a try on the
solution mentioned in above articles.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.
--------------------
>From: "Jonny Bergdahl" <>
>Subject: Re: Comet implementation in WCF
>Date: Thu, 15 Jan 2009 10:55:42 +0100
>> So far based on my research, at server-side, WCF method can use
>> "OperationContext.Current" to inspect some WCF method invocation context
>> info. And the OperationContext class has a "InstanceContext" property
that
>> can help inspect the current communication object's State:
>
>Sorry for the late reply, I haven't come around to this until now.
>
>I am sorry to report that this does not work. The
>OperationContext.Current.InstanceContext.State only seems to track the
>internal state of thre service object, and not the communication state.
>
>When I have initiated a connection from the client, State is set top
Opened.
>But even after I have closed down the Client, it is still set to Opened
even
>though the HTTP connection is closed.
>
>What I need is to keep track of the underlying HTTP connection state,
>something like HttpResponse.IsClientConnected.
>
>Any other ideas on how to get to the underlying connection?
>
>Regards;
>/jb
>
>