protected override void OnDisconnectedEvent(Session session, EDisconnectInfo disconnectInfo)
 {
     if (OnPeerDisconnected != null)
     {
         OnPeerDisconnected(session, disconnectInfo);
     }
 }
Пример #2
0
 private void SetNetConnectState(NetConnectState m_connectState, EDisconnectInfo info)
 {
     this.m_connectState = m_connectState;
     if (OnNetConnectStateChange != null)
     {
         OnNetConnectStateChange(m_connectState, info);
     }
 }
        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);
        }
Пример #4
0
 protected override void OnDisconnectedEvent(Session session, EDisconnectInfo disconnectInfo)
 {
     if (Configuration.UseStatistics && session != null)
     {
         clientNetStatistics.MarkDisconnect();
         clientNetStatistics.details.Add(session.statistics);
     }
     NetDebug.Log("Client DisconnectedEvent :" + session + " disconnectInfo:" + disconnectInfo.Reason);
     IsConnected = false;
     SetNetConnectState(NetConnectState.DisConnected, disconnectInfo);
 }
 public override bool Disconnect(long connectionId, EDisconnectReason disconnectReason)
 {
     try
     {
         if (!IsServer)
         {
             client.Disconnect();
             m_disconnectInfo = new EDisconnectInfo()
             {
                 Reason = disconnectReason
             };
         }
         else
         {
             server.Disconnect((int)connectionId);
         }
     }
     catch (Exception e)
     {
         NetDebug.LogError(e.ToString());
         return(false);
     }
     return(true);
 }
Пример #6
0
 public override void DisconnectedEvent(Session session, EDisconnectInfo disconnectInfo)
 {
     isConnect = false;
 }
 public virtual void DisconnectedEvent(Session session, EDisconnectInfo disconnectInfo)
 {
 }
Пример #8
0
 protected virtual void OnDisconnectedEvent(Session session, EDisconnectInfo disconnectInfo)
 {
 }