您是否需要在断开连接时手动从 SignalR 组中删除连接?
Do you need to manually remove a connection from a SignalR group on disconnect?
在 SignalR 集线器中,我在 OnConnected
方法中向组添加连接:
public override Task OnConnected()
{
this.Groups.Add(this.Context.ConnectionId, "aGroup");
this.Groups.Add(this.Context.ConnectionId, "bGroup");
}
我是否需要在断开连接时手动从这些组中删除连接?考虑到发布-订阅模型,除了在单独的数据结构中跟踪连接和组之外,我看不出如何轻松地做到这一点。
我在使用 SignalR 的 MVC 项目中遇到相当大的内存泄漏,我想知道这是否是罪魁祸首。
不,你不知道。
You don't have to explicitly create groups. In effect, a group is
automatically created the first time you specify its name in a call to
Groups.Add, and it is deleted when you remove the last connection from
membership in it.
来源,并进一步阅读:http://www.asp.net/signalr/overview/guide-to-the-api/working-with-groups
在 SignalR 集线器中,我在 OnConnected
方法中向组添加连接:
public override Task OnConnected()
{
this.Groups.Add(this.Context.ConnectionId, "aGroup");
this.Groups.Add(this.Context.ConnectionId, "bGroup");
}
我是否需要在断开连接时手动从这些组中删除连接?考虑到发布-订阅模型,除了在单独的数据结构中跟踪连接和组之外,我看不出如何轻松地做到这一点。
我在使用 SignalR 的 MVC 项目中遇到相当大的内存泄漏,我想知道这是否是罪魁祸首。
不,你不知道。
You don't have to explicitly create groups. In effect, a group is automatically created the first time you specify its name in a call to Groups.Add, and it is deleted when you remove the last connection from membership in it.
来源,并进一步阅读:http://www.asp.net/signalr/overview/guide-to-the-api/working-with-groups