次のコンソール アプリを使用します
static void Main(string[] args)
{
Thread connector = new Thread(Connector);
connector.Start();
while (true)
{
Thread.Sleep(500);
}
}
private static void Connector()
{
SignalR.Client.Hubs.HubConnection connection = new SignalR.Client.Hubs.HubConnection("http://192.168.42.10:1327/Chat");
SignalR.Client.Hubs.IHubProxy loginHub = connection.CreateProxy("LoginHub");
connection.Received += connection_Received;
connection.Reconnected += connection_Reconnected;
connection.StateChanged += connection_StateChanged;
connection.Error += connection_Error;
connection.Closed += connection_Closed;
connection.Start().Wait();
}
LoginHub は IDisconnect を実装します。
アプリを起動して接続し、ネットワーク ケーブルを引き、サーバー側の切断イベントが発生するのを待ち、ネットワーク ケーブルを再接続すると、クライアントが再接続され、すぐに接続が閉じられます。
サーバー側の切断が発生する前にネットワークケーブルを抜き差しすると、接続は正常に再接続されます。
これは意図した動作ですか?再接続はどのように機能するはずですか?