简体   繁体   English

C#WCF中的发布/订阅模式

[英]Publish/Subscribe Pattern in C# WCF

How to register client on server to listen some change? 如何在服务器上注册客户端以监听某些更改? I want to notify my client and send some data when something changed on my server. 当服务器上发生更改时,我想通知客户端并发送一些数据。 Also, I use NetTcpBinding. 另外,我使用NetTcpBinding。 I tried many examples, but I can't get method from server to register in. I don't have any config file. 我尝试了许多示例,但无法从服务器获取方法进行注册。我没有任何配置文件。

Thanks in advance. 提前致谢。

There is example of registering client on server. 有在服务器上注册客户端的示例。

ChannelFactory<ITrending> factory = new ChannelFactory<ITrending>(
            new NetTcpBinding(), new EndpointAddress(@"net.tcp://localhost:6000/ITrending"));

        proxy = factory.CreateChannel();

You can use the CallBack functionality in WCF services , it can be used for sending the changes in any entity or object value. 您可以在WCF服务中使用CallBack功能,它可以用于发送任何实体或对象值中的更改。 In this case, Client must act as a server and server as a Client to receive the updates based on the method in the Client which is receiving the changes. 在这种情况下,客户端必须充当服务器,而服务器必须充当客户端,才能根据正在接收更改的客户端中的方法来接收更新。 More detailed explanation : http://www.dotnetcurry.com/wcf/721/push-data-wcf-callback-service 更详细的说明: http : //www.dotnetcurry.com/wcf/721/push-data-wcf-callback-service

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM