예제 #1
0
        /// <summary>
        /// Called from within the IO-Context
        /// </summary>
        /// <param name="client"></param>
        /// <param name="accountName"></param>
        internal static void InitializeAccount(IRealmClient client, string accountName)
        {
            if (!client.IsConnected)
            {
                return;
            }

            if (RealmServer.Instance.IsAccountLoggedIn(accountName))
            {
                log.Info("Client ({0}) tried to use online Account: {1}.", client, accountName);
                AuthenticationHandler.OnLoginError(client, AccountStatus.AccountInUse);
                client.Disconnect();
                return;
            }
            var addr = client.ClientAddress;

            if (addr == null)
            {
                return;
            }
            var accountInfo = new AccountInfo
            {
                AccountId     = client.AuthAccount.AccountId,
                EmailAddress  = "",
                LastIP        = client.ClientAddress.GetAddressBytes(),
                LastLogin     = DateTime.Now,
                RoleGroupName = client.AuthAccount.RoleGroupName
            };
            var account = new RealmAccount(accountName, accountInfo);

            RealmServer.Instance.RegisterAccount(account);
            account.LoadCharacters();
            account.LoadAccountData();

            account.Client = client;
            client.Account = account;

            log.Info("Account \"{0}\" logged in from {1}.", accountName, client.ClientAddress);
        }
예제 #2
0
        /// <summary>Called from within the IO-Context</summary>
        /// <param name="client"></param>
        /// <param name="accountName"></param>
        internal static void InitializeAccount(IRealmClient client, string accountName)
        {
            if (!client.IsConnected)
            {
                return;
            }
            if (ServerApp <WCell.RealmServer.RealmServer> .Instance.IsAccountLoggedIn(accountName))
            {
                RealmAccount.log.Info("Client ({0}) tried to use online Account: {1}.", (object)client,
                                      (object)accountName);
                AuthenticationHandler.OnLoginError(client, AccountStatus.AccountInUse);
                client.Disconnect(false);
            }
            else
            {
                if (client.ClientAddress == null)
                {
                    return;
                }
                AccountInfo accountInfo = new AccountInfo()
                {
                    AccountId     = client.AuthAccount.AccountId,
                    EmailAddress  = "",
                    LastIP        = client.ClientAddress.GetAddressBytes(),
                    LastLogin     = new DateTime?(DateTime.Now),
                    RoleGroupName = client.AuthAccount.RoleGroupName
                };
                RealmAccount acc = new RealmAccount(accountName, (IAccountInfo)accountInfo);
                ServerApp <WCell.RealmServer.RealmServer> .Instance.RegisterAccount(acc);

                acc.LoadCharacters();
                acc.LoadAccountData();
                acc.Client     = client;
                client.Account = acc;
                RealmAccount.log.Info("Account \"{0}\" logged in from {1}.", (object)accountName,
                                      (object)client.ClientAddress);
            }
        }
예제 #3
0
		/// <summary>
		/// Called from within the IO-Context
		/// </summary>
		/// <param name="client"></param>
		/// <param name="accountName"></param>
		internal static void InitializeAccount(IRealmClient client, string accountName)
		{
			if (!client.IsConnected)
			{
				return;
			}

			if (RealmServer.Instance.IsAccountLoggedIn(accountName))
			{
				log.Info("Client ({0}) tried to use online Account: {1}.", client, accountName);
				LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_ALREADY_ONLINE);
			}
			else if (!RealmServer.Instance.AuthClient.IsConnected)
			{
				LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_DB_BUSY);
			}
			else if (ValidateAuthentication(client, accountName))
			{
				// else request it from the AuthServer
				var addr = client.ClientAddress;
				if (addr == null)
				{
					return;
				}

				var accountInfo = RealmServer.Instance.RequestAccountInfo(accountName, addr.GetAddressBytes());

				if (accountInfo == null)
				{
					// Account not found
					RealmServer.Instance.Error(client, Resources.FailedToRetrieveAccount, accountName);

					LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_UNKNOWN_ACCOUNT);
					return;
				}

				// create new Account with newly fetched account-info
				var account = new RealmAccount(accountName, accountInfo);

				//if (!account.IsActive)
				//{
				//    // Account is inactive (banned)
				//    LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_BANNED);
				//    return;
				//}

				if (RealmServerConfiguration.Status != RealmStatus.Open && !account.Role.IsStaff)
				{
					// RealmServer is locked and only staff members may join
					LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_LOCKED_ENFORCED);
					return;
				}

				RealmServer.Instance.RegisterAccount(account);
				account.LoadCharacters();
			    account.LoadAccountData();

				account.Client = client;
				client.Account = account;

				log.Info("Account \"{0}\" logged in from {1}.", accountName, client.ClientAddress);

				if (RealmServer.Instance.ClientCount > RealmServerConfiguration.MaxClientCount &&
					!account.Role.MaySkipAuthQueue)
				{
					AuthQueue.EnqueueClient(client);
				}
				else
				{
					LoginHandler.InviteToRealm(client);
				}
			}
		}
예제 #4
0
        /// <summary>
        /// Called from within the IO-Context
        /// </summary>
        /// <param name="client"></param>
        /// <param name="accountName"></param>
        internal static void InitializeAccount(IRealmClient client, string accountName)
        {
            if (!client.IsConnected)
            {
                return;
            }

            if (RealmServer.Instance.IsAccountLoggedIn(accountName))
            {
                log.Info("Client ({0}) tried to use online Account: {1}.", client, accountName);
                LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_ALREADY_ONLINE);
            }
            else if (!RealmServer.Instance.AuthClient.IsConnected)
            {
                LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_DB_BUSY);
            }
            else if (ValidateAuthentication(client, accountName))
            {
                // else request it from the AuthServer
                var addr = client.ClientAddress;
                if (addr == null)
                {
                    return;
                }

                var accountInfo = RealmServer.Instance.RequestAccountInfo(accountName, addr.GetAddressBytes());

                if (accountInfo == null)
                {
                    // Account not found
                    RealmServer.Instance.Error(client, Resources.FailedToRetrieveAccount, accountName);

                    LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_UNKNOWN_ACCOUNT);
                    return;
                }

                // create new Account with newly fetched account-info
                var account = new RealmAccount(accountName, accountInfo);

                //if (!account.IsActive)
                //{
                //    // Account is inactive (banned)
                //    LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_BANNED);
                //    return;
                //}

                if (RealmServerConfiguration.Status != RealmStatus.Open && !account.Role.IsStaff)
                {
                    // RealmServer is locked and only staff members may join
                    LoginHandler.SendAuthSessionErrorReply(client, LoginErrorCode.AUTH_LOCKED_ENFORCED);
                    return;
                }

                RealmServer.Instance.RegisterAccount(account);
                account.LoadCharacters();
                account.LoadAccountData();

                account.Client = client;
                client.Account = account;

                log.Info("Account \"{0}\" logged in from {1}.", accountName, client.ClientAddress);

                if (RealmServer.Instance.ClientCount > RealmServerConfiguration.MaxClientCount &&
                    !account.Role.MaySkipAuthQueue)
                {
                    AuthQueue.EnqueueClient(client);
                }
                else
                {
                    LoginHandler.InviteToRealm(client);
                }
            }
        }