コード例 #1
0
 /// <summary>
 /// Updates the AuthServer about the login-status of the account with the given name.
 /// Accounts that are flagged as logged-in cannot connect again until its unset again.
 /// Called whenever client connects/disconnects.
 /// </summary>
 /// <param name="acc"></param>
 /// <param name="loggedIn"></param>
 internal void SetAccountLoggedIn(RealmAccount acc, bool loggedIn)
 {
     if (loggedIn)
     {
         acc.OnLogin();
     }
     else
     {
         acc.OnLogout();
     }
 }
コード例 #2
0
ファイル: RealmServer.cs プロジェクト: NecroSharper/WCell
 /// <summary>
 /// Removes the given Account from the list from currently connected Accounts.
 /// Requires IO-Context.
 /// </summary>
 /// <returns>Whether the Account was even flagged as logged in.</returns>
 internal void UnregisterAccount(RealmAccount acc)
 {
     acc.ActiveCharacter = null;
     if (LoggedInAccounts.ContainsKey(acc.Name))
     {
         LoggedInAccounts.Remove(acc.Name);
     }
     else
     {
         Log.Warn("Tried to unregister non-registered account: " + acc);
     }
 }
コード例 #3
0
ファイル: RealmServer.cs プロジェクト: NecroSharper/WCell
        /// <summary>
        /// Gets all information of the account with the given Name.
        /// </summary>
        /// <remarks>Requires IO-Context.</remarks>
        /// <returns>The information of the requested account or null if the Account
        /// did not exist or the AuthServer could not be reached</returns>
        public RealmAccount GetOrRequestAccount(string accountName)
        {
            RealmAccount acc;

            if (!LoggedInAccounts.TryGetValue(accountName, out acc))
            {
                if (m_authServiceClient.IsConnected)
                {
                    var info = m_authServiceClient.Channel.RequestAccountInfo(accountName, null);
                    if (info != null)
                    {
                        acc = new RealmAccount(accountName, info);
                    }
                }
            }
            return(acc);
        }
コード例 #4
0
ファイル: RealmServer.cs プロジェクト: NecroSharper/WCell
 /// <summary>
 /// Updates the AuthServer about the login-status of the account with the given name.
 /// Accounts that are flagged as logged-in cannot connect again until its unset again.
 /// Called whenever client connects/disconnects.
 /// </summary>
 /// <param name="acc"></param>
 /// <param name="loggedIn"></param>
 internal void SetAccountLoggedIn(RealmAccount acc, bool loggedIn)
 {
     if (m_authServiceClient.IsConnected)
     {
         if (loggedIn)
         {
             acc.OnLogin();
             m_authServiceClient.Channel.SetAccountLoggedIn(acc.Name);
         }
         else
         {
             acc.OnLogout();
             IOQueue.AddMessage(new Message1 <RealmAccount>(acc, UnregisterAccount));
             m_authServiceClient.Channel.SetAccountLoggedOut(acc.Name);
         }
     }
 }
コード例 #5
0
ファイル: RealmAccount.cs プロジェクト: 0xFh/Asda2-Project
        /// <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);
        }
コード例 #6
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);
            }
        }
コード例 #7
0
        /// <summary>Called when a client disconnects</summary>
        /// <param name="client">the client object</param>
        /// <param name="forced">indicates if the client disconnection was forced</param>
        protected override void OnClientDisconnected(IClient client, bool forced)
        {
            IRealmClient client1 = client as IRealmClient;

            if (client1 != null && !client1.IsOffline)
            {
                client1.IsOffline = true;
                if (client1.AuthAccount != null)
                {
                    client1.AuthAccount.IsLogedOn = false;
                }
                LoginHandler.NotifyLogout(client1);
                RealmAccount account = client1.Account;
                if (account != null)
                {
                    account.Client = (IRealmClient)null;
                    Character chr = client1.ActiveCharacter;
                    if (chr != null && client1.IsGameServerConnection)
                    {
                        chr.IsConnected = false;
                        chr.AddMessage((Action)(() =>
                        {
                            if (chr.IsAsda2Teleporting)
                            {
                                chr.IsAsda2Teleporting = false;
                            }
                            else
                            {
                                chr.Logout(true, 0);
                            }
                        }));
                    }
                }
            }

            --this.m_acceptedClients;
            base.OnClientDisconnected(client, forced);
        }
コード例 #8
0
ファイル: RealmServer.cs プロジェクト: 0xFh/Asda2-Project
 /// <summary>
 /// Removes the given Account from the list from currently connected Accounts.
 /// Requires IO-Context.
 /// </summary>
 /// <returns>Whether the Account was even flagged as logged in.</returns>
 internal void UnregisterAccount(RealmAccount acc)
 {
     if (acc == null)
     {
         return;
     }
     acc.ActiveCharacter = null;
     if (LoggedInAccounts.ContainsKey(acc.Name))
     {
         SetAccountLoggedIn(acc, false);
         LoggedInAccounts.Remove(acc.Name);
         LoggedInAccountsById.Remove((uint)acc.AccountId);
         if (IPC.IPCServiceAdapter.AllConnectedClients.ContainsKey(acc.Name))
         {
             var ipcClient = IPC.IPCServiceAdapter.AllConnectedClients[acc.Name];
             ipcClient.CurrentAccount = null;
         }
     }
     else
     {
         Log.Warn("Tried to unregister non-registered account: " + acc);
     }
 }
コード例 #9
0
 /// <summary>
 /// Removes the given Account from the list from currently connected Accounts.
 /// Requires IO-Context.
 /// </summary>
 /// <returns>Whether the Account was even flagged as logged in.</returns>
 internal void UnregisterAccount(RealmAccount acc)
 {
     if (acc == null)
     {
         return;
     }
     acc.ActiveCharacter = (Character)null;
     if (this.LoggedInAccounts.ContainsKey(acc.Name))
     {
         this.SetAccountLoggedIn(acc, false);
         this.LoggedInAccounts.Remove(acc.Name);
         this.LoggedInAccountsById.Remove((uint)acc.AccountId);
         if (!IPCServiceAdapter.AllConnectedClients.ContainsKey(acc.Name))
         {
             return;
         }
         IPCServiceAdapter.AllConnectedClients[acc.Name].CurrentAccount = (RealmAccount)null;
     }
     else
     {
         ServerApp <WCell.RealmServer.RealmServer> .Log.Warn(
             "Tried to unregister non-registered account: " + (object)acc);
     }
 }
コード例 #10
0
ファイル: RealmAccount.cs プロジェクト: KroneckerX/WCell
		/// <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);
				}
			}
		}
コード例 #11
0
ファイル: RealmServer.cs プロジェクト: NecroSharper/WCell
 /// <summary>
 /// Registers the given Account as currently connected.
 /// Requires IO-Context.
 /// </summary>
 internal void RegisterAccount(RealmAccount acc)
 {
     LoggedInAccounts.Add(acc.Name, acc);
     SetAccountLoggedIn(acc, true);
 }
コード例 #12
0
ファイル: RealmServer.cs プロジェクト: 0xFh/Asda2-Project
 /// <summary>
 /// Registers the given Account as currently connected.
 /// Requires IO-Context.
 /// </summary>
 internal void RegisterAccount(RealmAccount acc)
 {
     LoggedInAccounts.Add(acc.Name, acc);
     LoggedInAccountsById.Add((uint)acc.AccountId, acc);
     SetAccountLoggedIn(acc, true);
 }
コード例 #13
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);
                }
            }
        }
コード例 #14
0
ファイル: WCellUser.cs プロジェクト: WCell/WCell-IrcAddon
 public WCellUser(RealmAccount acc, IrcUser user)
 {
     IrcUser = user;
     m_Acc = acc;
     EntityId = EntityId.GetPlayerId(CharacterRecord.NextId());
 }