“OperationContext.Current.GetCallbackChannel”是什么意思实际上呢?
OperationContext.Current.GetCallbackChannel 实际上做了什么?它如何识别每个客户?
我的 WCF 服务遇到问题。如果两个以上的用户连接到该服务,我从服务发送到客户端的所有“有趣的更改”都将发送给第二个加入的用户。
例如,如果 A、B、C、D 加入服务,如果我通过回调将更改发送给 C 和 D,那么它将发送给 B。
有什么想法吗?
详细信息:
客户端:ASP.NET Web 应用程序
绑定:netTCPBinding
Update1
好的,我找到了问题的原因。我在 IIS 中托管了 asp.net 客户端。例如,客户端的 URL 为 http://url1。如果我在不同的计算机中打开页面的多个实例并加入服务,回调通道始终指向页面的第一个实例(我从不同的计算机打开站点)。但是,如果我在 IIS 中的不同站点下托管 asp.net 客户端,则回调通道是唯一的。对此有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当服务收到调用时,OperationContext.Current.GetCallbackChannel 将通道返回给该调用者。它不会返回向所有客户端广播的频道。
从您的问题来看,您可能只存储上次调用中检索到的回调。实际上,您必须存储一个列表,其中包含已检索到的每个唯一的回调实例。每次调用方法时,您都将回调实例添加到此列表中。当您想要广播时,您必须遍历列表中的每个项目并进行必要的调用。
如果您的服务使用 Singleton 实例模式,则实现对象可以将回调实例列表存储为数据成员。如果您的服务使用 Client 或 SingleCall 实例模式,那么您可以拥有一个包含回调实例列表的全局对象。
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.
您必须配置服务才能为每个会话创建单独的线程。
查看 http://msdn.microsoft.com/en-us/库/cc681240.aspx
You have to configurate your service to create separated thread for each session.
Take a look to http://msdn.microsoft.com/en-us/library/cc681240.aspx