不调用Signal R Client方法

时间:2016-06-30 05:34:45

标签: asp.net signalr chat

我使用信号 $("#1 #checkAll").click(function () { if ($("#1 #checkAll").is(':checked')) { $("#1 input[type=checkbox]").each(function () { $(this).prop("checked", true); }); } else { $("#1 input[type=checkbox]").each(function () { $(this).prop("checked", false); }); } }); $("#2 #checkAll2").click(function () { if ($("#2 #checkAll2").is(':checked')) { $("#2 input[type=checkbox]").each(function () { $(this).prop("checked", true); }); } else { $("#2 input[type=checkbox]").each(function () { $(this).prop("checked", false); }); } }); $('#c1').on('click', function(){ var $$ = $(this) if( !$$.is('.checked')){ $('#checkAll').prop('checked', true); } else { $$.removeClass('checked'); $$.addClass('unchecked'); $('#checkAll').prop('checked', false); } }) $('#c2').on('click', function(){ var $$ = $(this) if( !$$.is('.checked')){ $('#checkAll2').prop('checked', true); } else { $$.removeClass('checked'); $$.addClass('unchecked'); $('#checkAll2').prop('checked', false); } }) 开发了简单的聊天系统。

如果互联网断开连接并在2分钟后重新连接,则所有信号r R正在调用,但server methods未获得响应。

有人可以告诉我该怎么办?

1 个答案:

答案 0 :(得分:0)

如果互联网断开连接,那么signalR客户端也是如此。您将需要处理重新连接。以下代码是下面站点的示例,向您展示如何在发生断开连接时不断尝试重新连接signalR。

$.connection.hub.disconnected(function() {
   setTimeout(function() {
       $.connection.hub.start();
   }, 5000); // Restart connection after 5 seconds.
});

可在此处找到更多信息:http://www.asp.net/signalr/overview/guide-to-the-api/handling-connection-lifetime-events

相关问题