/// <summary> /// Constructor /// </summary> /// <param name="Pid">The player account ID</param> public AccountEditForm(int Pid) { InitializeComponent(); this.AccountId = Pid; // Register for Events GpcmClient.OnSuccessfulLogin += GpcmClient_OnSuccessfulLogin; GpcmClient.OnDisconnect += GpcmClient_OnDisconnect; // Fill the account information boxes using (GamespyDatabase Database = new GamespyDatabase()) { Dictionary <string, object> User = Database.GetUser(AccountId); PlayerID.Value = AccountId = Int32.Parse(User["id"].ToString()); AccountNick.Text = User["name"].ToString(); AccountEmail.Text = User["email"].ToString(); // Disable options if user is online if (GamespyEmulator.IsPlayerConnected(AccountId)) { SatusLabel.Text = "Online (IP: " + User["lastip"].ToString() + ")"; UpdateBtn.Enabled = false; DeleteBtn.Enabled = false; DisconnectBtn.Enabled = true; } else { SatusLabel.Text = "Offline"; } } }
private string GetOnlineStatus(int Pid) { if (!GamespyEmulator.IsRunning) { return("offline"); } else { return((GamespyEmulator.IsPlayerConnected(Pid)) ? "online" : "offline"); } }
/// <summary> /// Event fire when disconnect button is pushed. Forces the account /// to log out. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DisconnectBtn_Click(object sender, EventArgs e) { GamespyEmulator.ForceLogout(AccountId); }