English 中文(简体)
信号R 连接/断开中枢引爆
原标题:SignalR connect/disconnect hub blows up
  • 时间:2012-05-23 19:18:58
  •  标签:
  • signalr
最佳回答

Here is a link to a similar question Is there a way to get number of connections in Signalr hub group?

如果这帮不上忙的话,你可以看看信号R0.5.1中新的连接状态文件。

<强度 > 连接状态变化

信号R 连接始终是用户的黑盒,这使得很难发现基本连接状态的变化。 我们已经在 JavaScript 客户端和.NET 客户端中披露了一个新的状态变化事件。 这允许您倾听状态变化,并以不同方式对变化作出反应。 举例来说,如果连接进入重新连接状态,10秒后无法恢复,用户就会收到一条信息:

var chat = $.connection.chat;
var timeout = null;
var interval = 10000;
chat.addMessage = function (msg) {
    $( #messages ).append( <li>  + msg +  </li> );
};
$.connection.hub.stateChanged(function (change) {
    if (change.newState === $.signalR.connectionState.reconnecting) {
        timeout = setTimeout(function () {
            $( #state ).css( backgroundColor ,  red )
                .html( The server is unreachable... );
        }, interval);
    } else if (timeout && change.newState === $.signalR.connectionState.connected) {
        $( #state ).css( backgroundColor ,  green )
            .html( The server is online );
        clearTimeout(timeout);
        timeout = null;
    }
});
$.connection.hub.start();
问题回答

暂无回答




相关问题
Enabling push notification with React.js and signalR

I need to enable pushnotifications using signalR import { HubConnectionBuilder} from @microsoft/signalr ; import jwt_decode from "jwt-decode"; let connection = null; ...

SignalR - how to detect disconnected clients

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 ...

信号呼唤 系统中其他地方的中枢客户

我建立了信号监测中心,供服务器和客户之间沟通。 中心服务器侧代码储存在一个称为Hooking.c的类别中。 我想要的是,能够采用Hooking所定义的方法。

Redirecting a user from within a SignalR Hub class

I have a button that users can click to bid on something. Each bid, broadcasts the latest bid to every other client. That s the reason why I m using SignalR. Now, the user needs to have active ...

热门标签