Best use of SignalR Hub

2019-08-23 00:29发布

In my app, I have different parts, like Products, People, Suppliers, etc that they are entities which I defined as a Table in Db, and each part has separated page and its own logic for instant client update according to the Database changes. Also, I have some general rules for sending messages to Users and Groups. In this application, users can chat with them.

However, I really can't decide how should I implement these in my application? How many hubs do I need? Single hub and different methods or multiple hubs?

I think I have multiple hubs for each entity because it has a separate page and one hub for general rules and another for chat, but I don't know is it a good idea or not?

Thank you

1条回答
smile是对你的礼貌
2楼-- · 2019-08-23 01:17

According to the docs there is no performance difference.

Use that to form your own decision as you know all of your requirements. Some people will say yes, some will so no.

Here is a snippet of info from that link:

You can define multiple Hub classes in an application. When you do that, the connection is shared but groups are separate:

All clients will use the same URL to establish a SignalR connection with your service ("/signalr" or your custom URL if you specified one), and that connection is used for all Hubs defined by the service.

There is no performance difference for multiple Hubs compared to defining all Hub functionality in a single class.

查看更多
登录 后发表回答