async private Task <GameSession> SearchGameSessionsAsync() { Debug.Log("SearchGameSessions"); var searchGameSessionsRequest = new SearchGameSessionsRequest(); searchGameSessionsRequest.FleetId = FleetId; // can also use AliasId searchGameSessionsRequest.FilterExpression = "hasAvailablePlayerSessions=true"; // only ones we can join searchGameSessionsRequest.SortExpression = "creationTimeMillis ASC"; // return oldest first searchGameSessionsRequest.Limit = 1; // only one session even if there are other valid ones Task <SearchGameSessionsResponse> SearchGameSessionsResponseTask = _amazonGameLiftClient.SearchGameSessionsAsync(searchGameSessionsRequest); SearchGameSessionsResponse searchGameSessionsResponse = await SearchGameSessionsResponseTask; int gameSessionCount = searchGameSessionsResponse.GameSessions.Count; Debug.Log($"GameSessionCount: {gameSessionCount}"); if (gameSessionCount > 0) { Debug.Log("We have game sessions!"); Debug.Log(searchGameSessionsResponse.GameSessions[0].GameSessionId); return(searchGameSessionsResponse.GameSessions[0]); } return(null); }
public async void SearchRooms() { UnityEngine.Debug.Log("SearchRooms"); var response = await gameLiftClient.SearchGameSessionsAsync(new SearchGameSessionsRequest { AliasId = gameLiftAliasId, }); if (response.HttpStatusCode == HttpStatusCode.OK) { if (response.GameSessions.Count > 0) { gameSessionId = response.GameSessions[0].GameSessionId; } else { UnityEngine.Debug.Log("There is no room"); } } DebugUI.text = "SearchRoom: SessionID=" + gameSessionId; JoinRoom(); }
public GameSession SearchSession(string fleetId) { var req = new SearchGameSessionsRequest { FleetId = fleetId, FilterExpression = $"gameSessionProperties.roomName = '{RoomName}' AND hasAvailablePlayerSessions = true" }; var res = _glClient.SearchGameSessionsAsync(req).Result; if (res.GameSessions.Count < 1) { return(null); } foreach (var s in res.GameSessions) { Console.WriteLine($"session: {s.GameSessionId}, {s.CreationTime}"); } return(res.GameSessions.First()); }