/// <summary> /// Handles the keepalive packets every minute to remain in the server /// </summary> private void KeepAlive(Object adrr) { while (!stop) { try { Thread.Sleep(1000 * 30); KeepAliveInstruction ki = new KeepAliveInstruction(); List<KailleraInstruction> alive = new List<KailleraInstruction>(); alive.Add(ki); IPEndPoint adr = (IPEndPoint)adrr; log.Info("Sending keepalive packer to " + adr.ToString() + "with seq number " + ki.serial.ToString()); //Race condition here, should lock to prevent it if (stop) break; UDPMessenger.SendMessages(alive, adr, client); } catch (ThreadInterruptedException) { break; } } }
/// <summary> /// Only here for debugging purposes, not used otherwise. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void KeepAliveSameThread(object sender, ElapsedEventArgs e) { KeepAliveInstruction ki = new KeepAliveInstruction(); List<KailleraInstruction> alive = new List<KailleraInstruction>(); alive.Add(ki); log.Info("Sending keepalive packer to " + ip.ToString() + "with seq number " + ki.serial.ToString()); UDPMessenger.SendMessages(alive, ip, client); }