Exemplo n.º 1
0
        public override void OnConnect()
        {
            SNetEvent pEvent = new SNetEvent();

            pEvent.eType = ENetEvtType.NETEVT_ESTABLISH;
            FxNetModule.Instance().PushNetEvent(this, pEvent);

            IoThread.Instance().AddConnectSocket(this);
        }
Exemplo n.º 2
0
        public override void Disconnect()
        {
            if (m_hSocket != null && m_hSocket.Connected)
            {
                m_hSocket.Disconnect(false);
                m_hSocket = null;

                SNetEvent pEvent = new SNetEvent();
                pEvent.eType = ENetEvtType.NETEVT_TERMINATE;
                FxNetModule.Instance().PushNetEvent(this, pEvent);
                IoThread.Instance().DelConnectSocket(this);
            }
        }
Exemplo n.º 3
0
        public override void Disconnect()
        {
            if (m_hSocket != null && m_bIsConnected)
            {
                WebSocketSharp.WebSocket pSock = m_hSocket;

                m_bIsConnected = false;
                m_hSocket      = null;
                pSock.Close();

                SNetEvent pEvent = new SNetEvent();
                pEvent.eType = ENetEvtType.NETEVT_TERMINATE;
                FxNetModule.Instance().PushNetEvent(this, pEvent);
                IoThread.Instance().DelConnectSocket(this);
            }
        }
Exemplo n.º 4
0
        public override void ProcEvent(SNetEvent pEvent)
        {
            switch (pEvent.eType)
            {
            case ENetEvtType.NETEVT_ESTABLISH:
            {
                m_pSession.OnConnect();
                IoThread.Instance().AddConnectSocket(this);
            }
            break;

            case ENetEvtType.NETEVT_RECV:
            {
                m_pSession.OnRecv(m_pSessionBuffer.GetData(), pEvent.dwValue);
                m_pSessionBuffer.PopData(pEvent.dwValue);
            }
            break;

            case ENetEvtType.NETEVT_ERROR:
            {
                m_pSession.OnError(pEvent.dwValue);
            }
            break;

            case ENetEvtType.NETEVT_TERMINATE:
            {
                m_pSession.OnClose();
                SNetEvent oEvent = new SNetEvent();
                oEvent.eType = ENetEvtType.NETEVT_RELEASE;
                FxNetModule.Instance().PushNetEvent(this, oEvent);
            }
            break;

            case ENetEvtType.NETEVT_RELEASE:
                m_pSession.OnDestroy();
                break;

            default:
                break;
            }
        }