2012-12-12 72 views

回答

1

当连接中断时,客户端将进入重新连接。

因此,您可以扎入事件的重新连接时看到连接断开:

var connection = new Connection("http://myEndPointURL"); 

connection.Reconnecting +=() => 
{ 
    Console.WriteLine("The connection has gone down, shifting into reconnecting state"); 
}; 

希望这有助于!

+0

看起来这只是PersistentConnections支持的。我可以做一些与Hub相似的东西吗? – pcbliss

+0

集线器也有一个重新连接事件=) –

+0

其实,我没有看到重新连接作为我可以捕获的事件,只是重新连接。 – pcbliss

1

我能够捕获StateChanged来检测连接中的变化并通知用户。

 connection.StateChanged += (statechange) => 
      { 
       Console.WriteLine("Changing from " + statechange.OldState + " to " + statechange.NewState); 
      }; 

这给了我一个机制,在连接断开或成功重新连接时通知用户。

相关问题