调用GetCallbackChannel()时如何只获取一个实例?
我的 WCF 服务遇到一点问题。
实际上,用户可以订阅“发布”服务。
我只是在执行 OperationContext.Current.GetCallbackChannel
然后我将返回的对象添加到列表中(一种List
),
因为我希望在发布消息时通知我的客户,所以我只需调用所有订阅用户的回调。
它工作得很好,但用户可以订阅两次,但我不想这样做。
这就是为什么我执行 if (!theList.Contains(theCallbackChannelReturned)) 来验证此约束...
这里的事实是,每次我创建回调通道时,他似乎都会创建另一个新实例IPublishing 的,即使在同一个客户端上...
我不知道如何完成此操作...我发现 OperationContext.Current.InstanceContext
返回仍然相同的哈希码,但是 GetCallbackChannel 不...
谢谢!
I'm having a little problem with my WCF service.
Actually, a user can subscribe to a "publishing" service.
I'm simply doing a OperationContext.Current.GetCallbackChannel<IPublishing>();
Then I add the the returned object into a List (a kind of List<IPublishing>
)
As I want my clients to be notified when I publish a message, I simply call the callback of all the subscribed users.
It works great, but a user can subscribe twice and I don't want to.
It's why I do a if (!theList.Contains(theCallbackChannelReturned))
in order to verify this constraint...
The fact here is that everytime I create the callbackchannel, it seems that he create another new instance of IPublishing, even on the same client...
I don't know how to do to accomplish this... I figured out that OperationContext.Current.InstanceContext
returns still the same Hashcode but
GetCallbackChannel doesn't...
Thank you !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的客户端回调实现中,您应该执行以下操作:
In your client callback implementation you should do the following: