示例#1
0
        //-------------------------------------------------------------------------
        private void __Update(CNetTCPSocketConnect connect)
        {
            if (null == connect)
            {
                return;
            }

            int nID = SNetCommon.NUNE_VALUE;
            // 进入连接器 状态回调
            ENUM_SOCKET_STATE sState = connect.Update(out nID);

            if (nID == m_ReadyToConnectSID)
            {
                m_currentConnectState = sState;
                m_currentConnectedSID = m_ReadyToConnectSID;
            }

            // 消息取出来 外部进行消息分发
            if (connect.IsConnect())
            {
                List <SocketNetPacket> packList = new List <SocketNetPacket>();
                connect.GetAllReceivePack(packList);
                foreach (SocketNetPacket tempack in packList)
                {
                    NetMessageRecieveHandle.GetInstance().OnRecvMessage(tempack);
                }
            }
        }
示例#2
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// 连接器更新
        /// </summary>
        public ENUM_SOCKET_STATE Update(out int nID)
        {
            ENUM_SOCKET_STATE sState = ENUM_SOCKET_STATE.eSocket_DisConnected;

            nID = m_nSocketID;

            if (null != m_NetStateListener)
            {
                if (m_IPAddrMsg.m_IsNeedCallConnected)
                {
                    sState = ENUM_SOCKET_STATE.eSocket_Connected;
                    m_NetStateListener.del_OnConnectSuccess(m_nSocketID);
                    m_IPAddrMsg.m_IsNeedCallConnected = false;
                }
                else if (m_IPAddrMsg.m_IsNeedCallDisConnect)
                {
                    sState = ENUM_SOCKET_STATE.eSocket_DisConnected;
                    m_NetStateListener.del_OnDisconnect(m_nSocketID);
                    m_IPAddrMsg.m_IsNeedCallDisConnect = false;
                }
            }

            if (m_IPAddrMsg.m_IsNeedClose)
            {
                DisConnection();
                return(sState);
            }

            if (null != m_NetStateListener)
            {
                m_NetStateListener.del_Update(m_nSocketID);
            }

            return(sState);
        }
示例#3
0
        //-------------------------------------------------------------------------
        private void __Update(INetConnect connect)
        {
            if (null == connect)
            {
                return;
            }

            // 连接更新
            ENUM_SOCKET_STATE sState = connect.Update();
        }
示例#4
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// 断开连接
        /// </summary>
        /// <param name="id"></param>
        public void Disconnect(int id)
        {
            CNetTCPSocketConnect c = null;

            if (m_TCPConnects.TryGetValue(id, out c))
            {
                if (null != c)
                {
                    Debug.Log("CNetTCPWork::Disconnect Remove ID = " + id);
                    c.DisConnection();
                    m_TCPConnects[id] = null;
                    if (id == m_currentConnectedSID)
                    {
                        m_currentConnectState = ENUM_SOCKET_STATE.eSocket_DisConnected;
                    }
                }
                m_TCPConnects.Remove(id);
            }
        }
示例#5
0
        //-------------------------------------------------------------------------
        #endregion

        #region private method
        //-------------------------------------------------------------------------
        private void __Clear()
        {
            m_currentConnectedSID = SNetCommon.NUNE_VALUE;
            m_currentConnectState = ENUM_SOCKET_STATE.eSocket_DisConnected;
            m_ReadyToConnectSID   = SNetCommon.NUNE_VALUE;
        }
示例#6
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// 断开连接
        /// </summary>
        /// <param name="id"></param>
        public void Disconnect(int id)
        {
            CNetTCPSocketConnect c = null;

            if (m_TCPConnects.TryGetValue(id, out c))
            {
                if (null != c)
                {
                    Debug.Log("CNetTCPWork::Disconnect Remove ID = " + id);
                    c.DisConnection();
                    m_TCPConnects[id] = null;
                    if (id == m_currentConnectedSID)
                    {
                        m_currentConnectState = ENUM_SOCKET_STATE.eSocket_DisConnected;
                    }
                }
                m_TCPConnects.Remove(id);

            }
        }
示例#7
0
        //-------------------------------------------------------------------------
        private void __Update(CNetTCPSocketConnect connect)
        {
            if (null == connect)
            {
                return;
            }

            int nID = SNetCommon.NUNE_VALUE;
            // 进入连接器 状态回调
            ENUM_SOCKET_STATE sState = connect.Update(out nID);
            if (nID == m_ReadyToConnectSID)
            {
                m_currentConnectState = sState;
                m_currentConnectedSID = m_ReadyToConnectSID;
            }

            // 消息取出来 外部进行消息分发
            if (connect.IsConnect())
            {
                List<SocketNetPacket> packList = new List<SocketNetPacket>();
                connect.GetAllReceivePack(packList);
                foreach (SocketNetPacket tempack in packList)
                {
                    NetMessageRecieveHandle.GetInstance().OnRecvMessage(tempack);
                }
            }
        }
示例#8
0
 //-------------------------------------------------------------------------
 private void __Clear()
 {
     m_currentConnectedSID = SNetCommon.NUNE_VALUE;
     m_currentConnectState = ENUM_SOCKET_STATE.eSocket_DisConnected;
     m_ReadyToConnectSID = SNetCommon.NUNE_VALUE;
 }