简体   繁体   English

WCF服务可以使用SignalR通知客户更改吗?

[英]Can a WCF service use SignalR to notify clients of a change?

I have a mature client/service project that uses WCF services for the data access. 我有一个成熟的客户端/服务项目,该项目使用WCF服务进行数据访问。 These are called from a WPF client. 这些是从WPF客户端调用的。

We now want to add notifications to the project, so have been looking at SignalR to push those notifications to the clients. 现在,我们想向项目中添加通知,因此一直在寻找SignalR将这些通知推送给客户端。 This all works fine when it's SignalR itself that's initiating the push, say a client sends a SignalR notification to the server, the server can then notify all other clients. 当是SignalR本身启动推送时,这一切都很好,例如,客户端将SignalR通知发送到服务器,然后服务器可以通知所有其他客户端。

However, as all of our data access is done via the WCF services, I want to be able to send out a SignalR notification in response to a WCF service call. 但是,由于我们所有的数据访问都是通过WCF服务完成的,因此我希望能够发出SignalR通知以响应WCF服务调用。 For example, a client calls the UpdateCustomer() service call, which saves the modified customer data to the database. 例如,客户调用UpdateCustomer()服务调用,该服务将修改后的客户数据保存到数据库中。 I then want to notify all other clients of the change. 然后,我想将所有更改通知所有其他客户。 However, at this stage I'm in the WCF service code, not the SignalR code. 但是,在此阶段,我使用的是WCF服务代码,而不是SignalR代码。

How do I tell SignalR to send out a notification? 如何告诉SignalR发送通知?

Ah, found it just after posting! 嗯,发布后就发现了!

Predictably, it was in the SignalR docs, How to call client methods and manage groups from outside the Hub class . 可以预见,这是在SignalR文档中, 如何从Hub类外部调用客户端方法和管理组

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

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