问题描述
在我的应用程序中,我有不同的部分,例如产品,人员,供应商等,它们是我在Db中定义为表格的实体,并且每个部分都有单独的页面,并且根据自己的逻辑可以根据客户端即时更新数据库更改.另外,我有一些向用户和组发送消息的一般规则.在此应用程序中,用户可以与他们聊天.
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?
谢谢
推荐答案
根据文档没有性能差异.
根据您的所有要求,使用它来形成自己的决定.有些人会说是,有些人会说不.
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:
您可以在一个应用程序中定义多个Hub类.当您这样做时,连接是共享的,但组是分开的:
You can define multiple Hub classes in an application. When you do that, the connection is shared but groups are separate:
所有客户端将使用相同的URL与您的服务建立SignalR连接("/signalr"或您的自定义URL(如果已指定)),并且该连接将用于该服务定义的所有集线器.
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.
这篇关于最佳使用SignalR集线器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!