コード例 #1
0
 public void HandleCommand(Client.Client sender, string[] parameter)
 {
     if (_AuthenticationService.TryGetSession(sender, out Session session))
     {
         sender.SendServerNotification(string.Format(Resources.Msg_LoggedIn, session.Account.UserName));
     }
     else
     {
         sender.SendServerNotification(Resources.Msg_NotLoggedIn);
     }
 }
コード例 #2
0
        public void HandleCommand(Client.Client sender, string[] parameter)
        {
            if (sender == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            _AuthenticationService.LogoutClient(sender);
            sender.SendServerNotification(Resources.Msg_YouHaveBeenLoggedOut);
        }
コード例 #3
0
        public async void HandleCommand(Client.Client sender, string[] parameter)
        {
            if (parameter.Length != 2)
            {
                sender.SendServerNotification(string.Format(Resources.Msg_CommandRequiresNArguments, Identifiers, 2));
            }

            string userName = parameter[0];
            string password = parameter[1];

            LoginResult result = await _AuthenticationService.CreateAndLoginAccountAsync(sender, userName, password);

            if (result is LoginSuccessfulResult successfulResult)
            {
                sender.SendServerNotification(Resources.Msg_AccountSuccessfullyCreated);
                sender.SendServerNotification(string.Format(Resources.Msg_LoginSuccessful, successfulResult.Session.Account.UserName));
            }
            else
            {
                sender.SendServerNotification(Resources.Msg_AccountCreationFailed);
            }
        }