Ejemplo n.º 1
0
        /// <summary>
        /// 데이터 수신 처리 콜백 함수
        /// </summary>
        /// <param name="ar"></param>
        private void OnReceiveCallBack(IAsyncResult ar)
        {
            try
            {
                StateObject so = (StateObject)ar.AsyncState;

                int bytesRead = so.Worker.EndReceive(ar);

                AsyncSocketReceiveEventArgs rev = new AsyncSocketReceiveEventArgs(this.id, bytesRead, so.Buffer);

                // 데이터 수신 이벤트를 처리한다.
                if (bytesRead > 0)
                {
                    Received(rev);
                }

                // 다음 읽을 데이터를 처리한다.
                Receive();
            }
            catch (System.Exception e)
            {
                AsyncSocketErrorEventArgs eev = new AsyncSocketErrorEventArgs(this.id, e);

                ErrorOccured(eev);
            }
        }
Ejemplo n.º 2
0
        protected virtual void Received(AsyncSocketReceiveEventArgs e)
        {
            AsyncSocketReceiveEventHandler handler = OnReceive;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Ejemplo n.º 3
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));
            }
        }
Ejemplo n.º 4
0
 private void OnReceive(object sender, AsyncSocketReceiveEventArgs e)
 {
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 데이터 수신 처리 콜백 함수
        /// </summary>
        /// <param name="ar"></param>
        private void OnReceiveCallBack(IAsyncResult ar)
        {
            try
            {
                StateObject so = (StateObject)ar.AsyncState;

                int bytesRead = so.Worker.EndReceive(ar);

                AsyncSocketReceiveEventArgs rev = new AsyncSocketReceiveEventArgs(this.id, bytesRead, so.Buffer);

                // 데이터 수신 이벤트를 처리한다.
                if (bytesRead > 0)
                    Received(rev);

                // 다음 읽을 데이터를 처리한다.
                Receive();
            }
            catch (System.Exception e)
            {
                AsyncSocketErrorEventArgs eev = new AsyncSocketErrorEventArgs(this.id, e);

                ErrorOccured(eev);
            }
        }
Ejemplo n.º 6
0
        protected virtual void Received(AsyncSocketReceiveEventArgs e)
        {
            AsyncSocketReceiveEventHandler handler = OnReceive;

            if (handler != null)
                handler(this, e);
        }