Example #1
0
 private void CheckAlive(CancellationToken token)
 {
     try
     {
         while (true)
         {
             if (PongMissed > 1)
             {
                 Console.WriteLine("No pong received for 30000 ms, {0}", PongMissed);
             }
             if (PongMissed > 5)
             {
                 Console.WriteLine("Missed {0} pongs, retrying connection", PongMissed);
                 this.Reconnect();
                 return;
             }
             Thread.Sleep(30000);
             SlackClient.SendPing();
             PongMutex.WaitOne();
             PongMissed += 1;
             PongMutex.ReleaseMutex();
         }
     }
     catch (System.OperationCanceledException)
     {
         Console.WriteLine("Cancelled the pong thread");
         return;
     }
 }
Example #2
0
 private void PingTimerAction(object state)
 {
     if (!IsConnected)
     {
         return;
     }
     if (!_client.IsConnected)
     {
         Core.Log.Warning("Is disconnected and should be connected. Reconnecting.");
         _client.Connect(connected =>
         {
             Core.Log.InfoBasic("Connected.");
         }, () =>
         {
             Core.Log.LibDebug("Socket connected, waiting for RTM start.");
         });
     }
     else
     {
         Core.Log.LibDebug("Sending ping");
         _client.SendPing();
     }
 }