简体   繁体   English

WCF服务中的SignalR更新网站客户端

[英]SignalR in WCF service to update web site clients

Using SignalR, is it possible to update website clients from my WCF service if the service is not used by these clients directly? 使用SignalR,如果我的WCF服务未直接使用这些网站的客户端,是否可以从中更新网站客户端?

I have a desktop application in .NET which has WCF service used internally using net.TCP protocol. 我在.NET中有一个桌面应用程序,该应用程序内部使用net.TCP协议使用WCF服务。 This application changes one of the status fields in database table depending on certain user actions. 此应用程序根据某些用户操作来更改数据库表中的状态字段之一。 I want to notify this change to end users who are accessing a different website hosted on the same web server. 我想将此更改通知正在访问同一Web服务器上托管的其他网站的最终用户。

I have tried one SignalR sample where notification works fine if it is sent from same website's host to its own client (stock ticker sample). 我尝试了一个SignalR示例,如果通知是从同一网站的主机发送到其自己的客户端的,则该通知可以正常工作(股票报价器示例)。 But in my case, the message should go from WCF service to a website client. 但就我而言,该消息应该从WCF服务发送到网站客户端。

IMO you should do an intermediate hop, for example having your website exposing an endpoint (you pick the technology) where you can post whenever you have a change to notify. IMO,您应该做一个中间跃点,例如让您的网站公开一个端点(您选择技术),以便在您有任何更改要通知时可以在其中发布 Your WCF service would post there whenever there's a change, and the web app would process the post by broadcasting info to the target clients (can be all, or can be just some you filter with some logic behind the post). 您的WCF服务将在发生任何更改时发布到那里,并且Web应用程序将通过向目标客户端广播信息来处理发布(可以是全部,也可以只是您在发布后加上一些逻辑过滤的某些内容)。 I use this pattern quite frequently, implementing it with HTTP POST. 我经常使用此模式,并通过HTTP POST实施它。 You would have no issues to implement the SignalR infrastructure in the web app, which is where your clients already connect to. 您可以在客户端已经连接到的Web应用程序中实现SignalR基础架构没有任何问题。

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

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