简体   繁体   中英

Calling signalR hub methods from console application

I have a requirement like, when my database get updated with new data, I want to trigger the refreshAllClient method on signalR hub. This method call every client connected to my application and trigger refresh method on client. So that all users will have live record. Actually the data are coming from different sources(multiple clients), when the data are ready, console application will start to move data into database. Once date get updated, console application need to trigger method on signalR. How do I trigger signalR hub from console application?

the key is this kind of thing

  var ctx = GlobalHost.ConnectionManager.GetHubContext<yourhub>();
  ctx.Clients.Client(connectionId).<your method>  

The point is you now have a hub context that allows sending to a client a group or all

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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