public async Task JoinGame(string type) { GameType value; GameType.TryParse(type, out value);//TODO: handle error! var user = await CurrentUser; var competitor = _gameService.JoinGame(user, value); //TODO: check if exists usersConnections[user] = Context.ConnectionId; if (competitor != null) { if (usersConnections.ContainsKey(user)) { await Clients.Client(usersConnections[user]).SendAsync("startGame", competitor.Login); } if (usersConnections.ContainsKey(competitor)) { await Clients.Client(usersConnections[competitor]).SendAsync("startGame", user.Login); } } }
public static bool TryParse(byte[] bytes, out GameType type) { return(GameType.TryParse(Encoding.UTF8.GetString(bytes), out type)); }