private void OnReceive(object sender, AsyncSocketReceiveEventArgs e) { AsyncSocketClient psocket = (AsyncSocketClient)sender; //AppManager.Instance.AddLog(Convert.ToString(e.ReceiveBytes)); Int16 len = System.BitConverter.ToInt16(e.ReceiveData, 0); if (len != e.ReceiveBytes) { AppManager.Instance.AddLog("패킷의 길이가 달라요"); return; } PACKET_IDX pidx = (PACKET_IDX)System.BitConverter.ToChar(e.ReceiveData, 2); switch (pidx) { case PACKET_IDX.CM_CHANNEL_IDX: { C_TO_M_CHANNEL_IDX p = new C_TO_M_CHANNEL_IDX(); PacketProcess.Deserialize(p, e.ReceiveData); if (Crawler_Connection_List_.ContainsKey(p.nIdx) == false) { Crawler_Connection_List_.Add(p.nIdx, psocket); } ChannelInfo_List_[p.nIdx].connected_ip_ = psocket.Connection.RemoteEndPoint.ToString(); ChannelInfo_List_[p.nIdx].crawler_status_ = "연결됨"; } break; case PACKET_IDX.KM_CHANNEL_IDX: { K_TO_M_CHANNEL_IDX p = new K_TO_M_CHANNEL_IDX(); PacketProcess.Deserialize(p, e.ReceiveData); if (Checker_Connection_List_.ContainsKey(p.nIdx) == false) { Checker_Connection_List_.Add(p.nIdx, psocket); } ChannelInfo_List_[p.nIdx].checker_status_ = "연결됨"; } break; default: { AppManager.Instance.AddLog("잘못된 패킷이 도착했습니다."); } break; } }
private void OnReceive(object sender, AsyncSocketReceiveEventArgs e) { try { LogManager.Instance.Log(string.Format("private void OnReceive {0}/{1}", sender.ToString(), e.ToString())); AsyncSocketClient psocket = (AsyncSocketClient)sender; Int16 len = System.BitConverter.ToInt16(e.ReceiveData, 0); if (len != e.ReceiveBytes) { return; } PACKET_IDX pidx = (PACKET_IDX)System.BitConverter.ToChar(e.ReceiveData, 2); switch (pidx) { case PACKET_IDX.MK_RESTART: { } break; case PACKET_IDX.CK_HEARTBEAT: { C_TO_K_HEARTBEAT p = new C_TO_K_HEARTBEAT(); PacketProcess.Deserialize(p, e.ReceiveData); if (p.CrawlingCount > CrawlingCount_) { CrawlingCountChangeTime_ = Environment.TickCount; LogManager.Instance.Log(string.Format("크롤링이 끝났다고 날라 왔구나. 고고싱~{0}", p.CrawlingCount)); CrawlingCount_ = p.CrawlingCount; } HeartBeatTime_ = Environment.TickCount; label_NextCheck.Text = string.Format("PACKET_IDX.CK_HEARTBEAT 패킷 도착{0}", HeartBeatTime_); } break; default: { } break; } } catch (System.Exception ex) { LogManager.Instance.Log(string.Format("private void Error OnReceive {0}", ex.Message)); } }