简体   繁体   中英

Avoid circular reference/coupling when using SignalR

Lets say I have a notification center in my app server that reads data from DB and send it to the clients. I thought that the notification center will run in the backgound in an infinite loop and when it fetch data from the DB it will trigger the hub with the data.

How do I do that without coupling my assemblies or worse, creating circular reference between my hub class(that sits in my web app) and the notification center (that sits in my app server)?

Do I have to create a loop in my hub that goes to the notification center and reads the data and whenever there is a data, send it to the client or is there a clean solution?

Thanks

You can create a background loop that does the checking for you. See my answer here:

https://stackoverflow.com/a/20965835/1574622

You of course don't have to have the "Looper" a part of the hub at all if you don't want.

Solved. I had the privilege to subscribe to event that I added to the notification center. A big plus for building all layers on the same app server/site

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