// 매칭 신청하기 // MatchType (1:1 / 개인전 / 팀전) // MatchModeType (랜덤 / 포인트 / MMR) public void RequestMatchMaking(int index) { // 매청 서버에 연결되어 있지 않으면 매칭 서버 접속 if (!isConnectMatchServer) { Debug.Log(NOTCONNECT_MATCHSERVER); Debug.Log(RECONNECT_MATCHSERVER); JoinMatchServer(); return; } // 변수 초기화 isConnectInGameServer = false; Debug.Log("매칭 요청중 ..."); Backend.Match.RequestMatchMaking(MatchType.MMR, MatchModeType.OneOnOne, matchInfos[index].inDate); if (isConnectInGameServer) { Backend.Match.LeaveGameServer(); //인게임 서버 접속되어 있을 경우를 대비해 인게임 서버 리브 호출 } nowMatchType = MatchType.MMR; nowModeType = MatchModeType.OneOnOne; numOfClient = int.Parse(matchInfos[index].headCount); Debug.Log(string.Format("매칭 중 ... 매칭 타입 : [{0}] / 매칭 모드 : [{1}] / 매칭 정보 [{2}]", MatchType.Random, MatchModeType.OneOnOne, matchInfos[index].inDate)); }
// 매칭된 매치 타입,모드 타입 설정 public void SetNowMatchInfo(MatchType matchType, MatchModeType matchModeType) { this.nowMatchType = matchType; this.nowModeType = matchModeType; Debug.Log(string.Format("매칭 타입/모드 : {0}/{1}", nowMatchType, nowModeType)); }
private void ProcessMatchSuccess(MatchMakingResponseEventArgs args) { ErrorInfo errorInfo; if (sessionIdList != null) { Debug.Log("이전 세션 정보 저장"); sessionIdList.Clear(); } if (!Backend.Match.JoinGameServer(args.RoomInfo.m_inGameServerEndPoint.m_address, args.RoomInfo.m_inGameServerEndPoint.m_port, false, out errorInfo)) { var debugLog = string.Format("실패", errorInfo.ToString(), string.Empty); Debug.Log(debugLog); } isConnectInGameServer = true; isJoinGameRoom = false; isReconnectProcess = false; inGameRoomToken = args.RoomInfo.m_inGameRoomToken; isSandBoxGame = args.RoomInfo.m_enableSandbox; var info = GetMatchInfo(args.MatchCardIndate); if (info == null) { Debug.LogError("매치 정보를 불러오는 데 실패했습니다."); return; } nowmatchType = info.matchType; nowModeType = info.matchModeType; numOfClient = int.Parse(info.HeadCount); }
// 매칭 성공했을 때 // 인게임 서버로 접속해야 한다. private void ProcessMatchSuccess(MatchMakingResponseEventArgs args) { ErrorInfo errorInfo; if (sessionIdList != null) { Debug.Log("이전 세션 저장 정보"); sessionIdList.Clear(); } if (!Backend.Match.JoinGameServer(args.RoomInfo.m_inGameServerEndPoint.m_address, args.RoomInfo.m_inGameServerEndPoint.m_port, false, out errorInfo)) { var debugLog = string.Format(FAIL_ACCESS_INGAME, errorInfo.ToString(), string.Empty); Debug.Log(debugLog); } // 인자값에서 인게임 룸토큰을 저장해두어야 한다. // 인게임 서버에서 룸에 접속할 때 필요 // 1분 내에 모든 유저가 룸에 접속하지 않으면 해당 룸은 파기된다. isConnectInGameServer = true; isJoinGameRoom = false; isReconnectProcess = false; inGameRoomToken = args.RoomInfo.m_inGameRoomToken; isSandBoxGame = args.RoomInfo.m_enableSandbox; var info = GetMatchInfo(args.MatchCardIndate); if (info == null) { Debug.LogError("매치 정보를 불러오는 데 실패했습니다."); return; } nowMatchType = info.matchType; nowModeType = info.matchModeType; numOfClient = int.Parse(info.headCount); }