Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "OperationContext.Current.GetCallbackChannel" actually do?

What does OperationContext.Current.GetCallbackChannel actually do? How does it identify each and every client?

I'm facing a problem in my WCF service. If more than two users get connected to the service all the "interesting Changes" i'm sending from service to the clients are going to the second joined user.

For ex, If A, B, C, D joins the service if i send the changes to C and D through callback it is going to B.

Any ideas?

Details:

Client : ASP.NET web app

Binding: netTCPBinding

Update1

Okie, i've found the cause of the issue. I've hosted the asp.net client in IIS. For example the URL of the client is http://url1. If i open multiple instances of the page in different machine and join the service the callback channel is always pointing to the first instance of the page (i open the site from different machines). But if i host the asp.net client under different sites in IIS the callback channels are unique. Any thoughts on that?

like image 246
NLV Avatar asked Jul 03 '10 11:07

NLV


1 Answers

When the service receives a call, OperationContext.Current.GetCallbackChannel returns a channel to just that caller. It does not return a channel that broadcasts to all of the clients.

From your question, it's possible that you are only storing the callback that was retrieved in the last call. You actually have to store a list, containing each unique callback instance that has been retrieved. Every time a method is called, you add the callback instance to this list. When you want to broadcast, you have to iterate through each item in the list and make the necessary call.

If your service uses the Singleton instance mode, the implementation object can store a list of callback instances as a data member. If your sevice uses the Client or SingleCall instance mode, then you could have a global object that contains the list of callback instances.

like image 71
Andrew Shepherd Avatar answered Sep 29 '22 16:09

Andrew Shepherd