Ejemplo n.º 1
0
        /// <summary>
        /// 关闭并清理网络管理器。
        /// </summary>
        internal override void Shutdown()
        {
            foreach (KeyValuePair <string, NetworkChannelBase> networkChannel in m_NetworkChannels)
            {
                NetworkChannelBase networkChannelBase = networkChannel.Value;
                networkChannelBase.NetworkChannelConnected     -= OnNetworkChannelConnected;
                networkChannelBase.NetworkChannelClosed        -= OnNetworkChannelClosed;
                networkChannelBase.NetworkChannelMissHeartBeat -= OnNetworkChannelMissHeartBeat;
                networkChannelBase.NetworkChannelError         -= OnNetworkChannelError;
                networkChannelBase.NetworkChannelCustomError   -= OnNetworkChannelCustomError;
                networkChannelBase.Shutdown();
            }

            m_NetworkChannels.Clear();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 销毁网络频道。
        /// </summary>
        /// <param name="name">网络频道名称。</param>
        /// <returns>是否销毁网络频道成功。</returns>
        public bool DestroyNetworkChannel(string name)
        {
            NetworkChannelBase networkChannel = null;

            if (m_NetworkChannels.TryGetValue(name ?? string.Empty, out networkChannel))
            {
                networkChannel.NetworkChannelConnected     -= OnNetworkChannelConnected;
                networkChannel.NetworkChannelClosed        -= OnNetworkChannelClosed;
                networkChannel.NetworkChannelMissHeartBeat -= OnNetworkChannelMissHeartBeat;
                networkChannel.NetworkChannelError         -= OnNetworkChannelError;
                networkChannel.NetworkChannelCustomError   -= OnNetworkChannelCustomError;
                networkChannel.Shutdown();
                return(m_NetworkChannels.Remove(name));
            }

            return(false);
        }