using System; using System.Collections.Generic; using System.Linq; using System.Text; using SN_Server.ServerMSGS; namespace SN_Server { public class ControlCmdHandler { private ServerConnector _sc; private System.Threading.Timer tSendPing; private System.Threading.Timer tCheckCSList; private System.Threading.Timer tCheckUnitList; private System.Threading.Timer tCheckRegUnitList; private System.Threading.Timer tCheckSMSlist; private System.Threading.Timer tCheckPOLLmsgs; public ControlCmdHandler(ServerConnector sc) { _sc = sc; //ping pong tSendPing = new System.Threading.Timer(PingCallBack, null, new TimeSpan(0, 0, 10), new TimeSpan(0, 0, 20)); //control server list command tCheckCSList = new System.Threading.Timer(CSListCallBack, null, new TimeSpan(0, 1, 0), new TimeSpan(0, 1, 0)); //unit list tCheckUnitList = new System.Threading.Timer(UnitListCallBack, null, new TimeSpan(0, 0, 1), new TimeSpan(0, 5, 5)); //register unit list //tCheckRegUnitList = new System.Threading.Timer(RegUnitListCallBack, null, new TimeSpan(0, 0, 5), new TimeSpan(365, 0, 5)); //sms tCheckSMSlist = new System.Threading.Timer(SMSListCallBack, null, new TimeSpan(0, 0, 3), new TimeSpan(0, 0, 30)); //poll tCheckPOLLmsgs = new System.Threading.Timer(PollMSGSCallBack, null, new TimeSpan(0, 0, 5), new TimeSpan(0, 0, 30)); } private void PingCallBack(Object state) { Console.WriteLine("Sendig Ping at:" +DateTime.Now); SM_PingPong smpingpong = new SM_PingPong(new SN_Server.ServerMSG()); byte[] dataPong = smpingpong.GenResponse(); _sc.Send(dataPong, dataPong.Length); } private void CSListCallBack(Object state) { byte[] dataMsg = SM_IPList.GenRequestMsg(); _sc.Send(dataMsg, dataMsg.Length); } private void UnitListCallBack(Object state) { byte[] dataMsg = SM_UnitList.GenRequestMsg(); _sc.Send(dataMsg, dataMsg.Length); } private void RegUnitListCallBack(Object state) { byte[] dataMsg = SM_UnitList.GenRequestRegMsg(); _sc.Send(dataMsg, dataMsg.Length); } private void SMSListCallBack(Object state) { byte[] dataMsg = SM_SMS.GenRequestMsg(); _sc.Send(dataMsg, dataMsg.Length); } private void PollMSGSCallBack(Object state) { byte[] dataMsg = SM_GPS.GenPollRequestMsg(); _sc.Send(dataMsg, dataMsg.Length); } } }