2012-12-12 71 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); 
      }; 

這給了我一個機制,在連接斷開或成功重新連接時通知用戶。

相關問題