protected void Disconnect(bool notify)
        {
            RealmServer.IOQueue.EnsureContext();

            if (m_ClientProxy != null &&
                m_ClientProxy.State != CommunicationState.Closed &&
                m_ClientProxy.State != CommunicationState.Closing)
            {
                AddDisconnectWarningToTitle();
                try
                {
                    if (notify && m_ClientProxy.State == CommunicationState.Opened)
                    {
                        RealmServer.Instance.UnregisterRealm();
                    }

                    lock (lck)
                    {
                        m_ClientProxy.Close();
                        m_ClientProxy = null;
                    }
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch
                {
                }
                // ReSharper restore EmptyGeneralCatchClause

                var evt = Disconnected;
                if (evt != null)
                {
                    evt(this, null);
                }
            }
        }
示例#2
0
        protected void Disconnect(bool notify)
        {
            ServerApp <RealmServer> .IOQueue.EnsureContext();

            if (m_ClientProxy == null || m_ClientProxy.State == CommunicationState.Closed ||
                m_ClientProxy.State == CommunicationState.Closing)
            {
                return;
            }
            AddDisconnectWarningToTitle();
            try
            {
                if (notify && m_ClientProxy.State == CommunicationState.Opened)
                {
                    ServerApp <RealmServer> .Instance.UnregisterRealm();
                }
                lock (lck)
                {
                    m_ClientProxy.Close();
                    m_ClientProxy = null;
                }
            }
            catch
            {
            }

            EventHandler disconnected = Disconnected;

            if (disconnected == null)
            {
                return;
            }
            disconnected(this, null);
        }