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); } }
public void HandleCommand(Client.Client sender, string[] parameter) { if (sender == null) { throw new ArgumentNullException(nameof(sender)); } _AuthenticationService.LogoutClient(sender); sender.SendServerNotification(Resources.Msg_YouHaveBeenLoggedOut); }
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); } }