Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
        private void OnConnet(object sender, AsyncSocketConnectionEventArgs e)
        {
            NewLogManager2.Instance.Log("연결 되었습니다.");
            C_TO_M_CHANNEL_IDX p = new C_TO_M_CHANNEL_IDX();

            p.num  = (byte)PACKET_IDX.CM_CHANNEL_IDX;
            p.len  = (Int16)Marshal.SizeOf(p);
            p.nIdx = CINIManager.Instance.channelseq_;

            byte[] sendbuffer = new byte[p.len];
            PacketProcess.Serialize(p, sendbuffer);
            ((AsyncSocketClient)sender).Send(sendbuffer);
        }
Ejemplo n.º 3
0
        private void OnConnet(object sender, AsyncSocketConnectionEventArgs e)
        {
            LogManager.Instance.Log("private void OnConnet(object sender, AsyncSocketConnectionEventArgs e)");
            LQCrawlerInfo      pInfo = CrawlerManager.Instance.GetCrawlerInfo();
            C_TO_M_CHANNEL_IDX p     = new C_TO_M_CHANNEL_IDX();

            p.num = (byte)PACKET_IDX.CM_CHANNEL_IDX;
            p.len = (Int16)Marshal.SizeOf(p);
            //p.nIdx = CrawlerInfoManager.Instance.channelidx_;
            p.nIdx = pInfo.nIdx_;

            byte[] sendbuffer = new byte[p.len];
            PacketProcess.Serialize(p, sendbuffer);
            ((AsyncSocketClient)sender).Send(sendbuffer);
        }
Ejemplo n.º 4
0
        // 매니저의 연결을 확인
        void CheckManager()
        {
            bool bNeedConnection = false;

            if (manager_socket_ == null)
            {
                bNeedConnection = true;
            }
            else
            {
                if (manager_socket_.Connection == null)
                {
                    bNeedConnection = true;
                }
                else
                {
                    if (manager_socket_.Connection.Connected == false)
                    {
                        bNeedConnection = true;
                    }
                    else
                    {
                        LQCrawlerInfo      pInfo = CrawlerManager.Instance.GetCrawlerInfo();
                        C_TO_M_CHANNEL_IDX p     = new C_TO_M_CHANNEL_IDX();
                        p.num  = (byte)PACKET_IDX.CM_CHANNEL_IDX;
                        p.len  = (Int16)Marshal.SizeOf(p);
                        p.nIdx = pInfo.nIdx_;
                        byte[] sendbuffer = new byte[p.len];
                        PacketProcess.Serialize(p, sendbuffer);
                        manager_socket_.Send(sendbuffer);
                    }
                }
            }

            if (bNeedConnection == true)
            {
                ManagerConnect();
            }
        }