2
这是我的JavaScript代码试图拦截事件。非常简单直接。SignalR不捕获重新连接客户端事件
$.connection.hub.reconnecting = function (cb) {
$('#hub-info').text(getDateTime() + ': reconnecting... '); //breakpoint
if(cb) cb();
};
$.connection.hub.reconnected = function (cb) {
$('#hub-info').text(getDateTime() + ': reconnected '); //breakpoint
if(cb) cb();
};
$.connection.hub.disconnected = function (cb) {
$('#hub-info').text(getDateTime() + ': disconnected '); //breakpoint
if(cb) cb();
};
$.connection.hub.start()
.done(function() {
//...
});
Hub start()
正确,没问题。但是,当连接丢失时,中断点不会被触发,这些功能都不会被触发。我知道signalR正在工作,因为我从控制台(Chrome调试器)获得以下输出。
[19:21:02] SignalR: Keep alive has been missed, connection may be dead/slow. jquery.signalR.js:84
[19:21:08] SignalR: Keep alive timed out. Notifying transport that connection has been lost. jquery.signalR.js:84
[19:21:10] SignalR: Closing the Websocket. jquery.signalR.js:84
[19:21:10] SignalR: webSockets reconnecting. query.signalR.js:84
[19:21:10] SignalR: Connecting to websocket endpoint 'ws://localhost/sr/reconnect?
我做错了什么?感谢您的帮助:)
SignalR版本(2.2.1)
它的工作原理! :D感谢您的帮助! – Tom