public CreatePlayerWaitingResponse Post(CreatePlayerWaiting request) { string playerId = Request.GetSessionId(); var nextGame = Cache.Get <string>(NextGame); try { if (nextGame == null) { var response = CreateGame(new CreateGameInstance { PlayerOneId = playerId }); nextGame = response.GameId; Cache.Set(NextGame, response.GameId); } else { JoinGame(new PlayerJoinGame { GameId = nextGame, PlayerId = playerId, PlayerDisplayerName = request.PlayerDisplayName }); Cache.Set <string>(NextGame, null); } } catch (Exception e) { Cache.Set <string>(NextGame, null); throw; } return(new CreatePlayerWaitingResponse { GameId = nextGame }); }
public CreatePlayerWaitingResponse Post(CreatePlayerWaiting request) { string playerId = Request.GetSessionId(); var nextGame = Cache.Get<string>(NextGame); try { if (nextGame == null) { var response = CreateGame(new CreateGameInstance { PlayerOneId = playerId }); nextGame = response.GameId; Cache.Set(NextGame, response.GameId); } else { JoinGame(new PlayerJoinGame { GameId = nextGame, PlayerId = playerId, PlayerDisplayerName = request.PlayerDisplayName }); Cache.Set<string>(NextGame, null); } } catch (Exception e) { Cache.Set<string>(NextGame, null); throw; } return new CreatePlayerWaitingResponse { GameId = nextGame }; }