static funapi.Matchmaking.Server.MatchState CheckMatchRequirements(funapi.Matchmaking.Match match) { // // 매치 완료 조건 검사 핸들러 함수입니다. // long total_players_for_match = MatchmakingType.GetNumberOfMaxPlayers(match.MatchType); // 총 플레이어 수가 매치 완료 조건에 부합하는 지 검사합니다. if (match.Players.Count != total_players_for_match) { // 아직 더 많은 플레이어가 필요합니다. Log.Info("Waiting for more players: match_id={0}, match_type={1}, total_players_for_match={2}, current players={3}", match.MatchId, match.MatchType, total_players_for_match, match.Players.Count); return(funapi.Matchmaking.Server.MatchState.kMatchNeedMorePlayer); } Log.Info("Matchmaking is done: match_id={0}, match_type={1}, total_players_for_match={2}, current players={3}", match.MatchId, match.MatchType, total_players_for_match, match.Players.Count); // 매치메이킹이 끝났으니 이 정보를 토대로 데디케이티드 서버 생성을 요청합니다. DedicatedServerHelper.SpawnDedicatedServer(match); return(funapi.Matchmaking.Server.MatchState.kMatchComplete); }
static void SpawnOrSendUser(string account_id, JObject user_data, long match_type) { Log.Assert(match_type == (long)MatchmakingType.MatchType.kNoMatching); // 1. 사람이 없고 인원이 부족한 서버를 찾아 난입을 시도합니다. // 2. 난입에 실패한 경우 새 서버를 생성합니다. DedicatedServerHelper.SendUserCallback cb = new DedicatedServerHelper.SendUserCallback((bool succeed) => { // 난입에 실패했습니다. 새 서버를 생성합니다. // 재시도를 하거나, 실패처리할 수 있습니다. if (!succeed) { Log.Info("Spawning a new dedicated server for: account_id={0}", account_id); DedicatedServerHelper.SpawnDedicatedServer(account_id, user_data); return; } // 매치 참여에 성공했습니다. 데디케이티드 서버 리다이렉션 메시지는 엔진 내부의 // 서버 오케스트레이터에서 자동으로 보내기 때문에 처리할 필요가 없습니다. // 게임 로직에 따라서는 아래 메시지 전송이 불필요할 수 있습니다. // 이 예제에서는 단순히 클라이언트에게 매치 참여 완료 메시지만 전달합니다. }); Log.Info("Trying to send user: account_id={0}", account_id); DedicatedServerHelper.SendUser(match_type, account_id, user_data, cb); }