private void OnAccountPlayersOnlineRefreshed(AccountPlayersOnline obj) { Invoke(() => { AccountPlayersOnline = obj; StateHasChanged(); }); }
public bool RetrieveAccountPlayerOnline(out AccountPlayersOnline accountPlayersOnline, out string message, out HttpStatusCode code) { message = ErrorCode.CONNECTION_FAILED; accountPlayersOnline = null; Api().CreateAuthenticated("api/account/online", "get") .Execute(out HttpWebResponse response); if (response.TryGetStatusCode(out code) && code == HttpStatusCode.OK) { ValidatedView <AccountPlayersOnline> validatedView = response.GetReponseString() .DeserializeJsonSafe <ValidatedView <AccountPlayersOnline> >(); if (validatedView == null) { message = ErrorCode.ERROR_WHILE_READING_RESULT; } else { accountPlayersOnline = validatedView.Object; message = validatedView.Message; return(validatedView.IsValid); } } return(false); }
protected override void OnInit() { if (!StateService.AccountPlayersOnline.Retrieve(out AccountPlayersOnline accountPlayersOnline, out string message, out _)) { NotificationService.ShowError(message, "Failed to load players online!"); AccountPlayersOnline = new AccountPlayersOnline(); } else { AccountPlayersOnline = accountPlayersOnline; } StateService.OnAccountPlayersOnlineRefreshed += OnAccountPlayersOnlineRefreshed; GameToken = "/game/" + GenerateGameToken(); _timerAccount = new Timer((x) => { GameToken = "/game/" + GenerateGameToken(); Invoke(StateHasChanged); }, null, TimeSpan.FromSeconds(30), TimeSpan.FromSeconds(30)); }
public bool RetrieveAccountPlayerOnline(out AccountPlayersOnline accountPlayersOnline, out string message) { return(RetrieveAccountPlayerOnline(out accountPlayersOnline, out message, out _)); }