public ZSocketClient(string host,int port) { Host = host; Port = port; cmdKeepAlive = new CmdKeepAlive(); cmdKeepAliveResp = new CmdKeepAliveResp(); OnCommand += ZSocketClient_OnCommand; OnSocketDisconnected += ZSocketClient_OnSocketDisconnected; RegistCommand<CmdKeepAlive>(); RegistCommand<CmdKeepAliveResp>(); RegistCommand<CmdRegistResp>(); }
public ZSocketServer() { sessionStateDict = new Dictionary<int, SessionState>();//key是socket的hashcode rwlForSessionStateDict = new ReaderWriterLock(); timerHeartbeats = new Timer(HeartbeatsRun, null, HEART_BEATS_TIMER_PERIOD_MILLI_SECS, HEART_BEATS_TIMER_PERIOD_MILLI_SECS); OnCommand += ZSocketServer_OnCommand; OnSocketDisconnected += ZSocketServer_OnSocketDisconnected; RegistCommand<CmdKeepAlive>(); RegistCommand<CmdKeepAliveResp>(); RegistCommand<CmdRegist>(); cmdKeepAlive = new CmdKeepAlive(); cmdKeepAliveResp = new CmdKeepAliveResp(); }
private void ProcessCommandKeepAlive(CmdKeepAlive cmdKeepAlive, Socket socket) { Send(socket, cmdKeepAliveResp); }