コード例 #1
0
        public override void Dispose()
        {
            foreach (KeyValuePair <string, SocketTcpRoutine> socketTcpRoutines in m_SocketTcpRoutines)
            {
                SocketTcpRoutine socket = socketTcpRoutines.Value;
                socket.SocketConnected   -= OnSocketConnected;
                socket.SocketClosed      -= OnSocketClosed;
                socket.SocketError       -= OnSocketError;
                socket.SocketCustomError -= OnSocketCustomError;
                socket.Shutdown();
            }

            m_SocketTcpRoutines.Clear();
        }
コード例 #2
0
        /// <summary>
        /// 销毁网络频道
        /// </summary>
        /// <param name="name">网络频道名称</param>
        /// <returns>是否销毁网络频道成功</returns>
        public bool DestroySocketTcpRoutine(string name)
        {
            SocketTcpRoutine socketTcpRoutine = null;

            if (m_SocketTcpRoutines.TryGetValue(name ?? string.Empty, out socketTcpRoutine))
            {
                socketTcpRoutine.SocketConnected   -= OnSocketConnected;
                socketTcpRoutine.SocketClosed      -= OnSocketClosed;
                socketTcpRoutine.SocketError       -= OnSocketError;
                socketTcpRoutine.SocketCustomError -= OnSocketCustomError;
                socketTcpRoutine.Shutdown();
                return(m_SocketTcpRoutines.Remove(name));
            }

            return(false);
        }