private void OnHandleEvent()
        {
            TransportEventData eventData     = netEventDatas.Dequeue();
            IMessageHandler    messageHander = configuration.GetMessageHander();
            Session            session       = eventData.session;

            //NetDebug.Log("循环接收事件1:" + eventData.type);
            switch (eventData.type)
            {
            case ENetworkEvent.ConnectEvent:
                if (messageHander != null)
                {
                    messageHander.OnConnectedEvent(session);
                }
                PeerConnectedEvent(session);
                break;

            case ENetworkEvent.DisconnectEvent:
                //NetDebug.Log(" ::OnPeerDisconnected peer.ConnectionId: " + eventData.connectionId + " disconnectInfo.Reason: " + eventData.disconnectInfo.Reason);
                if (messageHander != null)
                {
                    messageHander.OnDisconnectedEvent(session, eventData.disconnectInfo);
                }
                OnDisconnectedEvent(session, eventData.disconnectInfo);
                break;
            }
        }
        public override bool Receive(out TransportEventData eventData)
        {
            Telepathy.Message msg;
            bool state = false;

            if (IsServer)
            {
                state = server.GetNextMessage(out msg);
            }
            else
            {
                state = client.GetNextMessage(out msg);
            }

            if (state)
            {
                //NetDebug.Log("接收到消息:" + msg.eventType);
                ENetworkEvent msgType = ENetworkEvent.DataEvent;
                switch (msg.eventType)
                {
                case Telepathy.EventType.Connected:
                    msgType = ENetworkEvent.ConnectEvent;
                    break;

                case Telepathy.EventType.Data:
                    msgType = ENetworkEvent.DataEvent;
                    break;

                case Telepathy.EventType.Disconnected:
                    msgType = ENetworkEvent.DisconnectEvent;
                    break;

                default:
                    break;
                }
                eventData = new TransportEventData()
                {
                    type           = msgType,
                    connectionId   = msg.connectionId,
                    data           = msg.data,
                    disconnectInfo = this.m_disconnectInfo,
                };
                if (msgType == ENetworkEvent.DisconnectEvent)
                {
                    m_disconnectInfo = default(EDisconnectInfo);
                }
            }
            else
            {
                eventData = default(TransportEventData);
            }

            return(state);
        }
        public override bool Receive(out TransportEventData eventData)
        {
            SimpleTCP.Message msg;
            bool state = false;

            if (IsServer)
            {
                state = server.GetNextMessage(out msg);
            }
            else
            {
                state = client.GetNextMessage(out msg);
            }

            if (state)
            {
                //NetDebug.Log("接收到消息:" + msg.eventType);
                ENetworkEvent msgType = ENetworkEvent.DataEvent;
                switch (msg.eventType)
                {
                case SimpleTCP.EventType.Connected:
                    msgType = ENetworkEvent.ConnectEvent;
                    break;

                case SimpleTCP.EventType.Data:
                    msgType = ENetworkEvent.DataEvent;
                    break;

                case SimpleTCP.EventType.Disconnected:
                    msgType = ENetworkEvent.DisconnectEvent;
                    break;

                default:
                    break;
                }
                EDisconnectReason disReason = EDisconnectReason.ConnectionFailed;
                if (msg.disconnectReason == SimpleTCP.DisconnectReason.ConnectionFailed)
                {
                    disReason = EDisconnectReason.ConnectionFailed;
                }
                else if (msg.disconnectReason == SimpleTCP.DisconnectReason.DisconnectPeerCalled)
                {
                    disReason = EDisconnectReason.DisconnectPeerCalled;
                }

                eventData = new TransportEventData()
                {
                    type           = msgType,
                    connectionId   = msg.connectionId,
                    data           = msg.data,
                    disconnectInfo = new EDisconnectInfo()
                    {
                        Reason = disReason,
                    }
                };
            }
            else
            {
                eventData = default(TransportEventData);
            }

            return(state);
        }
 internal void AddNetEvent(TransportEventData eventData)
 {
     netEventDatas.Enqueue(eventData);
 }