SignalR - 如何检测断开连接的客户端

发布于 2024-12-08 07:14:20 字数 112 浏览 2 评论 0原文

如何检测哪些客户端已断开连接?我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2024-12-15 07:14:20

集线器上有一个客户端 ID 属性 (Context.ClientId),您可以使用它来确定哪个客户端已断开连接。

There's a Client id property on the Hub (Context.ClientId) that you can use to figure out which client disconnected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文