Comet implementation


J

Jonny Bergdahl

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 seem 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
 
Ad

Advertisements

S

Steven Cheng

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/2008/07/06/WCFNotificationOnDisconnect.asp
x

#Taking Action on Client Close
http://blogs.msdn.com/drnick/archive/2008/01/07/taking-action-on-client-clos
e.aspx

#Provide Way to Detect Client Abort/Disconnect in WCF
http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/7fb25e30-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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.


--------------------
 
J

Jonny Bergdahl

Unfortunately, the web service is consumed over the internet, so there is no
way to initiate a callback to the client.

Regards;
/jb
 
Ad

Advertisements

S

Steven Cheng

I've performed some further research. Seems normal request/response channel
cannot provide real-time detection on client-side disconnect. If you need
to have a reliable way for detecting, client-side must also expose an
endpoint that can be queried by the server-side.

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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: "Jonny Bergdahl" <[email protected]>
References: <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top