public SignalRGame GameToSignalR(Game currentGame) { if (currentGame == null) { return(null); } var gamer = _gamerStorage.GetGamer(currentGame.GamerId); return(new SignalRGame(gamer.Id, gamer.DisplayName, currentGame.Score, currentGame.Tries, currentGame.MaxTries)); }
public async Task StartGame(Guid id) { var gamer = _gamerStorage.GetGamer(id).ToMinimal(); await Task.Run(() => { _mqttHandler.PostGameStarted(gamer); }); }
public IActionResult Highscore(string qr) { var uri = configuration.GetValue <string>("ApiUri"); var gamerId = Guid.Parse(qr); var gamer = gamerContextMethods.GetGamer(gamerId); var userJson = new List <string>(); try { using (var client = new HttpClient()) { if (!float.TryParse(gamer.QrCode, out float number)) { userJson.Add($"Invalid QR: {gamer.QrCode}"); } var userUri = $"{uri}{gamer.QrCode}"; //var userUri = $"{uri}{"9626442211223632793001"}"; var task = client.GetStringAsync(userUri); task.Wait(); if (!task.IsCompletedSuccessfully) { throw new ApplicationException($"error on lookup. code: {task.Result}"); } userJson.Add(task.Result); } } catch (Exception ex) { userJson.Add($"Lookup failed for qr {gamer.QrCode}"); } var model = new HighscoreModel { UserJson = userJson }; return(View(model)); }