Beispiel #1
0
        internal static void AddRealm(RealmEntry realm)
        {
            m_realmsById.Add(realm.ChannelId, realm);

            var evt = RealmConnected;

            if (evt != null)
            {
                evt(realm);
            }

            Instance.UpdateTitle();
        }
Beispiel #2
0
        /// <summary>
        /// Marks an account as logged in or out.
        /// </summary>
        /// <param name="accName">the name of the account</param>
        internal void SetAccountLoggedIn(RealmEntry realm, string accName)
        {
            if (!m_loggedInAccounts.ContainsKey(accName))
            {
                m_loggedInAccounts.Add(accName, realm);
                log.Info("Account \"{0}\" logged into: {1}", accName, realm.Name);

                var evt = AccountLoggedIn;
                if (evt != null)
                {
                    evt(accName, realm);
                }
            }
        }
Beispiel #3
0
        internal static void RemoveRealm(RealmEntry realm, bool remove)
        {
            Instance.ClearAccounts(realm.ChannelId);

            realm.Flags  = RealmFlags.Offline;
            realm.Status = RealmStatus.Locked;

            //m_maintenanceTimer.Change(Timeout.Infinite, Timeout.Infinite);
            //m_maintenanceTimer.Dispose();

            if (remove && m_realmsById.Remove(realm.ChannelId))
            {
                var evt = RealmDisconnected;
                if (evt != null)
                {
                    evt(realm);
                }
            }
            Instance.UpdateTitle();
        }
Beispiel #4
0
        /// <summary>
        /// Registers a realm server with the authentication server
        /// </summary>
        /// <param name="serverName">the name of the server</param>
        /// <param name="serverType">the type of the server</param>
        /// <param name="flags">the up/down status of the serer (green/red)</param>
        /// <param name="serverCategory">the timezone the server is in</param>
        /// <param name="serverStatus">the status of the server (locked or not)</param>
        public void RegisterRealmServer(string serverName, string addr, int port, int chrCount, int capacity, 
			RealmServerType serverType, RealmFlags flags, RealmCategory serverCategory, 
			RealmStatus serverStatus, ClientVersion clientVersion)
        {
        	var context = OperationContext.Current;
			if (context == null)
			{
				return;
			}

        	var channel = context.Channel;
			if (channel == null)
			{
				return;
			}

            var id = GetCurrentId();
            var realm = AuthenticationServer.GetRealmById(id);
            var ep = GetCurrentEndPoint();

            // find out whether this server is just re-registering (came back online)
            var isNew = realm == null;

            if (isNew)
            {
                realm = AuthenticationServer.GetRealmByName(serverName);
                if (isNew = (realm == null))
				{
					if (!AuthServerConfiguration.RealmIPs.Contains(ep.Address))
					{
						// Ignore unknown realms
						log.Warn("Unallowed Realm (\"{0}\") tried to register from: {1}", serverName, ep.Address);
						var chan = OperationContext.Current.Channel;
						if (chan != null)
						{
							try
							{
								chan.Close();
							}
							catch (Exception) {}
						}
						return;
					}
                    realm = new RealmEntry();
                }
                realm.ChannelId = id;
            }

            if (string.IsNullOrEmpty(addr))
            {
                // no host given
                addr = ep.Address;
            }

            realm.Name = serverName;
            realm.Address = addr;
            realm.Port = port;
            realm.Flags = flags;
            realm.Status = serverStatus;
            realm.ServerType = serverType;
            realm.Category = serverCategory;
            realm.CharCount = chrCount;
            realm.CharCapacity = capacity;
        	realm.ClientVersion = clientVersion;

        	realm.Channel = channel;
            realm.ChannelAddress = ep.Address;
            realm.ChannelPort = ep.Port;


            if (isNew)
            {
                // register after setting all infos
                lock (AuthenticationServer.Realms)
                {
                    realm.ChannelId = id;
                    AuthenticationServer.Realms.Add(id, realm);
                }
            }
			log.Info(Resources.RealmRegistered, realm); //realm.ChannelAddress);
        }
Beispiel #5
0
 /// <summary>
 /// Sets an account as logged in
 /// </summary>
 /// <param name="accName">the account to log in</param>
 public void SetAccountLoggedIn(RealmEntry realm, string accName)
 {
     s_authServer.SetAccountLoggedIn(realm, accName);
 }
Beispiel #6
0
 /// <summary>
 /// Removes multiple accounts from the 'logged in' list
 /// </summary>
 /// <param name="accNames">the account names to log out</param>
 public void SetMultipleAccountsLoggedOut(RealmEntry realm, string[] accNames)
 {
     for (var i = 0; i < accNames.Length; i++)
     {
         s_authServer.SetAccountLoggedOut(accNames[i]);
     }
 }