in lambda/GameLiftUnreal-StartGameLiftSession.py [0:0]
def find_available_game_session():
game_sessions = game_lift.search_game_sessions(FleetId = GAMELIFT_FLEET_ID, FilterExpression = "hasAvailablePlayerSessions=true")
game_session = {}
if (len(game_sessions['GameSessions']) == 0):
# Create a new game session
game_session = game_lift.create_game_session(FleetId = GAMELIFT_FLEET_ID, MaximumPlayerSessionCount = 16)['GameSession']
# Wait for game session status to leave ACTIVATING state
game_session_status = "ACTIVATING"
while (game_session_status == "ACTIVATING"):
try:
session_details = game_lift.describe_game_session_details(GameSessionId = game_session['GameSessionId'])
game_session_status = session_details['GameSessionDetails'][0]['GameSession']['Status']
except:
break
# Sleep 10 ms between describe calls
time.sleep(0.01)
else:
# Use existing game session
game_session = game_sessions['GameSessions'][0]
return game_session