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);
        }
        /// <summary>
        /// Must be executed in RealmServer context
        /// </summary>
        protected bool Connect()
        {
            if (!m_warned)
            {
                AddDisconnectWarningToTitle();
                log.Info(Resources.ConnectingToAuthServer);
            }

            RealmServer.IOQueue.EnsureContext();

            Disconnect(true);

            m_ClientProxy        = new AuthenticationClientAdapter(binding, new EndpointAddress(m_netAddr));
            m_ClientProxy.Error += OnError;

            bool conn;

            try
            {
                m_ClientProxy.Open();

                //if (!RealmServer.Instance.IsRegisteredAtAuthServer)
                RealmServer.Instance.RegisterRealm();
                conn       = IsConnected;
                lastUpdate = DateTime.Now;
            }
            catch (Exception e)
            {
                m_ClientProxy = null;

                if (e is EndpointNotFoundException)
                {
                    if (!m_warned)
                    {
                        log.Error(Resources.IPCProxyFailed, UpdateInterval);
                    }
                }
                else
                {
                    LogUtil.ErrorException(e, Resources.IPCProxyFailedException, UpdateInterval);
                }
                conn = false;
            }
            m_warned = true;

            if (conn)
            {
                RearmDisconnectWarning();
                var evt = Connected;
                if (evt != null)
                {
                    evt(this, null);
                }
            }
            else
            {
                ScheduleReconnect();
            }
            return(conn);
        }
示例#4
0
        protected void Disconnect(bool notify)
        {
            ServerApp <WCell.RealmServer.RealmServer> .IOQueue.EnsureContext();

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

            EventHandler disconnected = this.Disconnected;

            if (disconnected == null)
            {
                return;
            }
            disconnected((object)this, (EventArgs)null);
        }
示例#5
0
        /// <summary>Must be executed in RealmServer context</summary>
        protected bool Connect()
        {
            if (!m_warned)
            {
                AddDisconnectWarningToTitle();
                log.Info(WCell_RealmServer.ConnectingToAuthServer);
            }

            ServerApp <RealmServer> .IOQueue.EnsureContext();

            Disconnect(true);
            m_ClientProxy =
                new AuthenticationClientAdapter(binding, new EndpointAddress(m_netAddr));
            m_ClientProxy.Error += OnError;
            bool flag;

            try
            {
                m_ClientProxy.Open();
                ServerApp <RealmServer> .Instance.RegisterRealm();

                flag       = IsConnected;
                lastUpdate = DateTime.Now;
            }
            catch (Exception ex)
            {
                m_ClientProxy = null;
                if (ex is EndpointNotFoundException)
                {
                    if (!m_warned)
                    {
                        log.Error(WCell_RealmServer.IPCProxyFailed,
                                  UpdateInterval);
                    }
                }
                else
                {
                    LogUtil.ErrorException(ex, WCell_RealmServer.IPCProxyFailedException, (object)UpdateInterval);
                }

                flag = false;
            }

            m_warned = true;
            if (flag)
            {
                RearmDisconnectWarning();
                EventHandler connected = Connected;
                if (connected != null)
                {
                    connected(this, null);
                }
            }
            else
            {
                ScheduleReconnect();
            }

            return(flag);
        }
示例#6
0
		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);
				}
			}
		}
示例#7
0
		/// <summary>
		/// Must be executed in RealmServer context
		/// </summary>
		protected bool Connect()
		{
			if (!m_warned)
			{
				AddDisconnectWarningToTitle();
				log.Info(Resources.ConnectingToAuthServer);
			}

			RealmServer.IOQueue.EnsureContext();

			Disconnect(true);
			
			m_ClientProxy = new AuthenticationClientAdapter(binding, new EndpointAddress(m_netAddr));
			m_ClientProxy.Error += OnError;

			bool conn;

			try
			{
                m_ClientProxy.Open();

				//if (!RealmServer.Instance.IsRegisteredAtAuthServer)
				RealmServer.Instance.RegisterRealm();
				conn = IsConnected;
				lastUpdate = DateTime.Now;
			}
			catch (Exception e)
			{
				m_ClientProxy = null;

				if (e is EndpointNotFoundException)
				{
					if (!m_warned)
					{
						log.Error(Resources.IPCProxyFailed, UpdateInterval);
						m_warned = true;
					}
				}
				else
				{
					LogUtil.ErrorException(e, Resources.IPCProxyFailedException, UpdateInterval);
				}
				conn = false;
			}

			if (conn)
			{
				RearmDisconnectWarning();
				var evt = Connected;
				if (evt != null)
				{
					evt(this, null);
				}
			}
			else
			{
				ScheduleReconnect();
			}
			return conn;
		}
示例#8
0
		/// <summary>
		/// Must be executed in RealmServer context
		/// </summary>
		protected bool Connect()
		{
			RealmServer.Instance.EnsureContext();

			Disconnect(true);
			
			m_ClientProxy = new AuthenticationClientAdapter(binding, new EndpointAddress(m_netAddr));
			m_ClientProxy.Error += OnError;

			bool conn;

			try
			{
                m_ClientProxy.Open();

				//if (!RealmServer.Instance.IsRegisteredAtAuthServer)
				RealmServer.Instance.RegisterRealm();
				conn = IsConnected;
				lastUpdate = DateTime.Now;
			}
			catch (Exception e)
			{
				m_ClientProxy = null;

				if (!(e is EndpointNotFoundException))
				{
                    LogUtil.ErrorException(e, Resources.IPCProxyFailedException, ReconnectInterval);
				}
				else
				{
					log.Error(Resources.IPCProxyFailed, ReconnectInterval);
				}
				conn = false;
			}

			if (conn)
			{
				var evt = Connected;
				if (evt != null)
				{
					evt(this, null);
				}
			}
			else
			{
				Reconnect();
			}
			return conn;
		}
示例#9
0
		public void Disconnect(bool notify)
		{
			if (m_ClientProxy != null &&
				m_ClientProxy.State != CommunicationState.Closed &&
			    m_ClientProxy.State != CommunicationState.Closing)
			{
				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);
				}
			}

			if (!m_IsRunning)
			{
				m_maintainConnTimer.Change(Timeout.Infinite, Timeout.Infinite);
			}
		}
示例#10
0
		public bool Connect()
		{
			Disconnect(true);
			Initialize();

			bool conn;

			try
			{
                m_ClientProxy.Open();

				//if (!RealmServer.Instance.IsRegisteredAtAuthServer)
				RealmServer.Instance.RegisterRealm();
				if (conn = IsConnected)
				{
					m_maintainConnTimer.Change(UpdateInterval * 1000, UpdateInterval * 1000);
				}
			}
			catch (Exception e)
			{
				m_ClientProxy = null;

				if (!(e is EndpointNotFoundException))
				{
                    LogUtil.ErrorException(e, Resources.IPCProxyFailedException, ReconnectInterval);
				}
				else
				{
					log.Error(Resources.IPCProxyFailed, ReconnectInterval);
				}
				conn = false;
			}

			if (conn)
			{
				var evt = Connected;
				if (evt != null)
				{
					evt(this, null);
				}
			}
			else
			{
				Reconnect();
			}
			return conn;
		}
示例#11
0
		void Initialize()
		{
			m_ClientProxy = new AuthenticationClientAdapter(binding, new EndpointAddress(m_netAddr));
			m_ClientProxy.Error += OnError;
		}
示例#12
0
        /// <summary>Must be executed in RealmServer context</summary>
        protected bool Connect()
        {
            if (!this.m_warned)
            {
                this.AddDisconnectWarningToTitle();
                AuthenticationClient.log.Info(WCell_RealmServer.ConnectingToAuthServer);
            }

            ServerApp <WCell.RealmServer.RealmServer> .IOQueue.EnsureContext();

            this.Disconnect(true);
            this.m_ClientProxy =
                new AuthenticationClientAdapter((Binding)this.binding, new EndpointAddress(this.m_netAddr));
            this.m_ClientProxy.Error += new Action <Exception>(this.OnError);
            bool flag;

            try
            {
                this.m_ClientProxy.Open();
                ServerApp <WCell.RealmServer.RealmServer> .Instance.RegisterRealm();

                flag            = this.IsConnected;
                this.lastUpdate = DateTime.Now;
            }
            catch (Exception ex)
            {
                this.m_ClientProxy = (AuthenticationClientAdapter)null;
                if (ex is EndpointNotFoundException)
                {
                    if (!this.m_warned)
                    {
                        AuthenticationClient.log.Error(WCell_RealmServer.IPCProxyFailed,
                                                       AuthenticationClient.UpdateInterval);
                    }
                }
                else
                {
                    LogUtil.ErrorException(ex, WCell_RealmServer.IPCProxyFailedException, new object[1]
                    {
                        (object)AuthenticationClient.UpdateInterval
                    });
                }

                flag = false;
            }

            this.m_warned = true;
            if (flag)
            {
                this.RearmDisconnectWarning();
                EventHandler connected = this.Connected;
                if (connected != null)
                {
                    connected((object)this, (EventArgs)null);
                }
            }
            else
            {
                this.ScheduleReconnect();
            }

            return(flag);
        }