Example #1
0
        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));
            }
        }
Example #2
0
        // 체커로의 연결을 확인
        void CheckChecker()
        {
            //LogManager.Instance.Log("체커 연결 확인");

            bool bNeedConnection = false;

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

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