private void SetProperties(Phoenix.Client.Client client, Guid id, bool loggedIn) { var loginData = _connections[client]; loginData.ID = id; loginData.LoggedIn = loggedIn; _connections[client] = loginData; }
private bool IsLoggedIn(Phoenix.Client.Client phoenixClient) { try { return(_connections[phoenixClient].LoggedIn); } catch (Exception ex) { Error(new MercuryErrorEventArgs { Exception = ex, Message = "Error checking this!" }); return(false); } }
/// <summary> /// Adds a new user to the lobby. /// </summary> /// <param name="user">the username of the person to add.</param> /// <param name="client">their client</param> /// <param name="rank">their rank</param> public static void Add(string user, ref Phoenix.Client.Client client, Rank rank) { if (!UserExists(user)) { SendMessage((new Action { SelectedAction = Actions.UserJoined, User = user }).ToByteArray()); lock (Users) Users.Add(new UserInformation { Username = user, Rank = rank, Client = client }); // build the user list. // client.Send(new LobbyUserList {}); } }
private void LoginCheck(Phoenix.Client.Client client, byte[] data) { Output(new MercuryOutputEventArgs { Output = "Login Routine called" }); var loginStructure = new Login(); loginStructure.Initialize(data); // Check to see if the ID exists if (Database.Buffer.Exists(loginStructure.ID)) { // Exists; make sure pass is good. if (Database.Buffer.Login(loginStructure.ID, loginStructure.Password)) { // Good login. SetProperties(client, loginStructure.ID, true); client.Send(new Response { Resp = Responses.LoginGood }.ToByteArray()); } else { // Bad login. client.Send(new Response { Resp = Responses.LoginBounced }.ToByteArray()); } } else { // Register the ID Database.Buffer.Register(loginStructure.ID, loginStructure.Password); SetProperties(client, loginStructure.ID, true); client.Send(new Response { Resp = Responses.LoginGood }.ToByteArray()); } }