SignalR - 如何检测断开连接的客户端
如何检测哪些客户端已断开连接?我正在使用 Hub,并看到了实现了 IDisconnect 接口的聊天示例。例如,当刷新或关闭页面时,会调用 Disconnect() 函数。工作正常,但如何检测哪一个已断开连接?
How to detect which clients was disconnected? I'm using Hub and saw the chat example where the IDisconnect
interface was implemented. De Disconnect()
function is called when a page is refreshed or closed, for example. It's working ok, but how to detect which one was disconnected ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
集线器上有一个客户端 ID 属性 (Context.ClientId),您可以使用它来确定哪个客户端已断开连接。
There's a Client id property on the Hub (Context.ClientId) that you can use to figure out which client disconnected.