public ResponseBase CreateGameSession(CreateGameSessionRequest createGameRequest) { var gameDetails = new GameSessionDetails { Name = createGameRequest.Name, Owner = createGameRequest.UserName, TotalPlayerCount = createGameRequest.MaxPlayers, TotalBotCount = createGameRequest.MaxBots, }; gameDetails.Players.Add(new PlayerDetails { ConnectionId = createGameRequest.ConnectionId, UserName = createGameRequest.UserName }); if (createGameRequest.MaxPlayers == 1) { gameDetails.PlayerStarts = createGameRequest.PlayerStarts; gameDetails.Status = GameStatus.Starting; this.gamesAdministrator.AddGame(gameDetails); var playerDetails = gameDetails.Players[0]; return(new LaunchGameResponse(gameDetails.Status, gameDetails.Id, playerDetails.Id, playerDetails.ConnectionId)); } else { gameDetails.Status = GameStatus.Open; this.waitingGameSessionsById.TryAdd(gameDetails.Id, gameDetails); return(new CreateGameSessionResponse(gameDetails.Id)); } }
void CreateGameSession(object maxPlayers) { LogToMyConsoleMainThread("CreateGameSession"); //Request must contain either GameSessionID or FleetID, but not both var request = new CreateGameSessionRequest() { FleetId = m_targetFleet, MaximumPlayerSessionCount = (int)maxPlayers, //GameSessionId = "gsess-abc" }; CreateGameSessionResponse CGSR = null; try { CGSR = m_Client.CreateGameSession(request); } catch (Exception ex) { Handler(ex); } if (CGSR == null) { LogToMyConsoleMainThread("Can't create game session"); } else { LogToMyConsoleMainThread("Game Session Created: " + CGSR.GameSession.GameSessionId); } }
public GameSession CreateGameSession() { Debug.Log("Creating a game session"); var gameSessionRequest = new CreateGameSessionRequest() { FleetId = m_targetFleet, CreatorId = m_uniqueId, MaximumPlayerSessionCount = 3, //TODO: This needs to be 3, 6, or 9 depending on what mode they selected. We also need to add this information to the GameProperties list so the server knows to initialize itself as a 3, 6, or 9 player server Name = "GameTest", //GameProperties = //List of keyValue pairs for custom properties about our game. Ex: How many players it is??? }; GameSession gameSession = null; try { CreateGameSessionResponse createGameSessionResponse = M_gameLiftClient.CreateGameSession(gameSessionRequest);//TODO: It Fails here gameSession = createGameSessionResponse.GameSession; Debug.Log("Game session created. ID: " + gameSession.GameSessionId); } catch (Exception ex) { Handler(ex); } Debug.Log("Done Creating a gamesession"); return(gameSession); }
public async Task <IActionResult> Create([FromBody] CreateGameSessionRequest request) { _logger.LogInformation("Received request to create player {PlayerName} and game {GameSessionName}", request.PlayerName, request.GameSessionName); var newGameResponse = await _gameSessionService.CreateGameAsync(request.PlayerName, request.GameSessionName); return(Ok(newGameResponse)); }
public CreateGameSessionResponse CreateGameSession(CreateGameSessionRequest gameSessionRequest) { string content = JsonConvert.SerializeObject(gameSessionRequest); string path = string.Format("/vendoruser/{0}/CreateGameSession", _vendorName); string response = Post(content, path); CreateGameSessionResponse createGameSessionResponse = JsonConvert.DeserializeObject <CreateGameSessionResponse>(response); return(createGameSessionResponse); }
void CreateGameSession(object myCreateGameSessionData) { LogToMyConsoleMainThread("CreateGameSession"); CreateGameSessionData CGSD = (CreateGameSessionData)myCreateGameSessionData; GameProperty GP0 = new GameProperty(); GP0.Key = "BoltPro"; #if !BOLT_CLOUD GP0.Value = "true"; #endif #if BOLT_CLOUD GP0.Value = "false"; #endif List <GameProperty> GPL = new List <GameProperty>(); GPL.Add(GP0); //Request must contain either GameSessionID or FleetID, but not both var request = new CreateGameSessionRequest() { FleetId = staticData.myFleetID, MaximumPlayerSessionCount = CGSD.maxPlayers, CreatorId = UniqueID, GameSessionData = CGSD.GameSessionData, GameProperties = GPL, Name = "Test" + randomNumber //GameSessionId = "gsess-abc" }; CreateGameSessionResponse CGSR = null; try { CGSR = m_Client.CreateGameSession(request); } catch (Exception ex) { Handler(ex); } if (CGSR == null) { LogToMyConsoleMainThread("Can't create game session"); } else { LogToMyConsoleMainThread("Game Session Created: " + CGSR.GameSession.GameSessionId); } }
public async Task <CreateGameSessionResponse> CreateGameSessionAsync(CreateGameSessionRequest request) { var response = ServiceMessageFactory <CreateGameSessionResponse> .CreateFrom(request); if (cache.FirstOrDefault(i => i.Id == request.GameSession.Id) == null) { cache.Add(request.GameSession); } else { response.Errors += "Game session already exists."; logger.LogError($"Game session ({request.GameSession.Id}) already exists."); } response.GameSession = request.GameSession; return(await Task.FromResult(response)); }
private GameSession CreateGameSession(string fleetId, string sid) { var props = new List <GameProperty> { new GameProperty { Key = "roomName", Value = RoomName } }; var createReq = new CreateGameSessionRequest { Name = RoomName, FleetId = fleetId, IdempotencyToken = sid, MaximumPlayerSessionCount = 4, GameProperties = props, }; var res = _glClient.CreateGameSessionAsync(createReq).Result; return(res.GameSession); }
public async void CreateRoom() { UnityEngine.Debug.Log("CreateRoom"); String roomName = Guid.NewGuid().ToString(); var request = new CreateGameSessionRequest { AliasId = gameLiftAliasId, MaximumPlayerSessionCount = 20, Name = roomName }; var response = await gameLiftClient.CreateGameSessionAsync(request); if (response.HttpStatusCode == HttpStatusCode.OK) { gameSessionId = response.GameSession.GameSessionId; } DebugUI.text = "CreateRoom: SessionID=" + gameSessionId; JoinRoom(); }
private void CreateSession() { GD.Print("no session found, creating new one"); CreateGameSessionRequest sessionRequest = new CreateGameSessionRequest() { MaximumPlayerSessionCount = 2, FleetId = PongServer }; try { CreateGameSessionResponse newSession = gameLiftClient.CreateGameSession(sessionRequest); GameSession session = newSession.GameSession; ConnectToSession(session); } catch (Exception e) { GD.Print(e); } }
public async Task <APIGatewayProxyResponse> Post(APIGatewayProxyRequest request, ILambdaContext context) { CreateGameRequest body = JsonSerializer.Deserialize <CreateGameRequest>(request.Body); AmazonGameLiftClient amazonClient = new AmazonGameLiftClient(Amazon.RegionEndpoint.USEast1); ListAliasesRequest aliasReq = new ListAliasesRequest(); aliasReq.Name = "WarshopServer"; Alias aliasRes = (await amazonClient.ListAliasesAsync(aliasReq)).Aliases[0]; DescribeAliasRequest describeAliasReq = new DescribeAliasRequest(); describeAliasReq.AliasId = aliasRes.AliasId; string fleetId = (await amazonClient.DescribeAliasAsync(describeAliasReq.AliasId)).Alias.RoutingStrategy.FleetId; CreateGameSessionRequest req = new CreateGameSessionRequest(); req.MaximumPlayerSessionCount = 2; req.FleetId = fleetId; req.CreatorId = body.playerId; req.GameProperties.Add(new GameProperty() { Key = "IsPrivate", Value = body.isPrivate.ToString() }); req.GameProperties.Add(new GameProperty() { Key = "Password", Value = body.password == null ? "" : body.password }); try { CreateGameSessionResponse res = await amazonClient.CreateGameSessionAsync(req); GameSession gameSession = res.GameSession; int retries = 0; while (gameSession.Status.Equals(GameSessionStatus.ACTIVATING) && retries < 100) { DescribeGameSessionsRequest describeReq = new DescribeGameSessionsRequest(); describeReq.GameSessionId = res.GameSession.GameSessionId; gameSession = (await amazonClient.DescribeGameSessionsAsync(describeReq)).GameSessions[0]; retries++; } CreatePlayerSessionRequest playerSessionRequest = new CreatePlayerSessionRequest(); playerSessionRequest.PlayerId = body.playerId; playerSessionRequest.GameSessionId = gameSession.GameSessionId; CreatePlayerSessionResponse playerSessionResponse = await amazonClient.CreatePlayerSessionAsync(playerSessionRequest); CreateGameResponse response = new CreateGameResponse { playerSessionId = playerSessionResponse.PlayerSession.PlayerSessionId, ipAddress = playerSessionResponse.PlayerSession.IpAddress, port = playerSessionResponse.PlayerSession.Port }; return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.OK, Body = JsonSerializer.Serialize(response), Headers = new Dictionary <string, string> { { "Content-Type", "application/json" } } }); } catch (NotFoundException e) { return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.NotFound, Body = "Your game is out of date! Download the newest version\n" + e.Message, }); } catch (FleetCapacityExceededException e) { return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.InternalServerError, Body = "Our game servers are too busy right now, come back later!\n" + e.Message, }); } catch (Exception e) { return(new APIGatewayProxyResponse { StatusCode = (int)HttpStatusCode.InternalServerError, Body = "An unexpected error occurred! Please notify the developers.\n" + e.Message, }); } }
public void CreateGameSessionAsync(CreateGameSessionRequest request, AmazonServiceCallback <CreateGameSessionRequest, CreateGameSessionResponse> callback, AsyncOptions options = null) { throw new System.NotImplementedException(); }