예제 #1
0
파일: UserSock.cs 프로젝트: 56059943/test1
        public void ProcessMessage()
        {
            m_AsyncEvent.Swap();

            AsyncEvent.RecvBufferData Data  = null;
            AsyncEvent.EventData      Event = null;

            while (m_AsyncEvent.PeekData(ref Data, ref Event))
            {
                if (Data != null)
                {
                    ReceiveData(Data.m_abyRecvBuffer, Data.m_iRecvSize);
                }
                else
                {
                    switch (Event.m_eEvent)
                    {
                    case AsyncEvent.e_SocketEvent.E_SOCKETEVENT_CONNECTED:
                        m_Callee.OnSockConnected(this, Event.m_strIP, Event.m_iPort);
                        break;

                    case AsyncEvent.e_SocketEvent.E_SOCKETEVENT_CONNECTFAILED:
                        m_Callee.OnSockConnectFail(this, Event.m_strIP, Event.m_iPort);
                        break;

                    case AsyncEvent.e_SocketEvent.E_SOCKETEVENT_CLOSED:
                        m_Callee.OnSockClose(this);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
예제 #2
0
        public void ProcessMessage()
        {
            AsyncEvent.RecvBufferData Data  = null;
            AsyncEvent.EventData      Event = null;

            while (m_AsyncEvent.PeekData(ref Data, ref Event))
            {
                ///处理内部网络事件
                if (Event != null)
                {
                    switch (Event.m_eEvent)
                    {
                    case AsyncEvent.e_SocketEvent.E_SOCKETEVENT_CONNECTED:
                        m_Callee.OnSockConnected(this, Event.m_strIP, Event.m_iPort);
                        break;

                    case AsyncEvent.e_SocketEvent.E_SOCKETEVENT_CONNECTFAILED:
                        m_Callee.OnSockConnectFail(this, Event.m_strIP, Event.m_iPort);
                        break;

                    case AsyncEvent.e_SocketEvent.E_SOCKETEVENT_CLOSED:
                        m_Callee.OnSockClose(this);
                        break;

                    default:
                        break;
                    }
                    return;
                }

                ///处理数据接收
                if (Data != null)
                {
                    ReceiveData(Data.m_abyRecvBuffer, Data.m_iRecvSize);
                    m_AsyncEvent.PushFreeData(Data);
                    Data = null;
                }
            }
        }