Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
                    }
                }
                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);
        }
Ejemplo n.º 3
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;
		}
Ejemplo n.º 4
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;
		}