예제 #1
0
 // Token: 0x06001ABD RID: 6845 RVA: 0x00072630 File Offset: 0x00070830
 public static void ProcessSourceSideException(Exception ex, NetworkChannel channel)
 {
     if (ex is NetworkTransportException || ex is OperationCanceledException)
     {
         channel.Close();
         return;
     }
     channel.SendException(ex);
 }
 // Token: 0x06002244 RID: 8772 RVA: 0x0009FB10 File Offset: 0x0009DD10
 private void DiscardChannel()
 {
     if (this.m_channel != null)
     {
         NetworkChannel channel = this.m_channel;
         this.m_channel = null;
         channel.Close();
     }
 }
예제 #3
0
        private void CloseChannel()
        {
            NetworkChannel netChannel = this.m_netChannel;

            if (netChannel != null)
            {
                this.m_netChannel = null;
                netChannel.Close();
                this.m_asyncNetWritePending = false;
            }
        }
        public Boolean Disconnect()
        {
            if (_client.IsConnected())
            {
                _client.Send(new Disconnect());
                _client.Close();
            }

            SetState(ConnectionState.NONE);
            return(true);
        }
예제 #5
0
        /// <summary>
        /// 关闭并清理网络管理器。
        /// </summary>
        internal override void Shutdown()
        {
            foreach (KeyValuePair <string, NetworkChannel> networkChannel in m_NetworkChannels)
            {
                NetworkChannel nc = networkChannel.Value;
                nc.Close();
                nc.NetworkChannelConnected     -= OnNetworkChannelConnected;
                nc.NetworkChannelClosed        -= OnNetworkChannelClosed;
                nc.NetworkChannelSended        -= OnNetworkChannelSended;
                nc.NetworkChannelReceived      -= OnNetworkChannelReceived;
                nc.NetworkChannelMissHeartBeat -= OnNetworkChannelMissHeartBeat;
                nc.NetworkChannelError         -= OnNetworkChannelError;
                nc.NetworkChannelCustomError   -= OnNetworkChannelCustomError;
            }

            m_NetworkChannels.Clear();
            m_EventPool.Shutdown();
        }
예제 #6
0
        /// <summary>
        /// 销毁网络频道。
        /// </summary>
        /// <param name="name">网络频道名称。</param>
        /// <returns>是否销毁网络频道成功。</returns>
        public bool DestroyNetworkChannel(string name)
        {
            NetworkChannel networkChannel = null;

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

            return(false);
        }
예제 #7
0
        internal static bool TestHealth(string targetServer, int targetPort, int timeOutInMs, out string errMsg)
        {
            errMsg = null;
            NetworkChannel networkChannel = null;
            Exception      ex             = null;

            ExTraceGlobals.TcpChannelTracer.TraceFunction <string>(0L, "TcpHealthCheck: testing {0}", targetServer);
            try
            {
                ushort num = (ushort)targetPort;
                if (num == 0)
                {
                    num = 64327;
                }
                ITcpConnector tcpConnector = Dependencies.TcpConnector;
                NetworkPath   netPath      = tcpConnector.BuildDnsNetworkPath(targetServer, (int)num);
                networkChannel = NetworkChannel.Connect(netPath, TcpChannel.GetDefaultTimeoutInMs(), false);
                TestHealthRequest testHealthRequest = new TestHealthRequest(networkChannel);
                testHealthRequest.Send();
                NetworkChannelMessage message = networkChannel.GetMessage();
                if (!(message is TestHealthReply))
                {
                    networkChannel.ThrowUnexpectedMessage(message);
                }
                ExTraceGlobals.TcpChannelTracer.TraceFunction <string>(0L, "TcpHealthCheck: {0} is healthy", targetServer);
                return(true);
            }
            catch (NetworkRemoteException ex2)
            {
                ex = ex2.InnerException;
            }
            catch (NetworkTransportException ex3)
            {
                ex = ex3;
            }
            catch (Win32Exception ex4)
            {
                ex = ex4;
            }
            catch (COMException ex5)
            {
                ex = ex5;
            }
            catch (ClusCommonFailException ex6)
            {
                ex = ex6;
            }
            catch (ClusCommonTransientException ex7)
            {
                ex = ex7;
            }
            finally
            {
                if (networkChannel != null)
                {
                    networkChannel.Close();
                }
            }
            if (ex != null)
            {
                ExTraceGlobals.TcpChannelTracer.TraceError <Exception>(0L, "TcpHealthCheck: failed: {0}", ex);
                errMsg = ex.Message;
            }
            return(false);
        }
예제 #8
0
 void OnApplicationQuit()
 {
     _channel.Close();
 }