public void CloseAllConnections() { if (m_ConnectionGame != null) { if (m_ConnectionGame.State != SFConnection.ConnectionState.DISCONNECTED) { if (mGameSvrDisConnectedAction != null) { mGameSvrDisConnectedAction(this, m_Game); } } } if (m_ConnectionLogin != null) { if (m_ConnectionLogin.State != SFConnection.ConnectionState.DISCONNECTED) { if (mLoginDisConnectedAction != null) { mLoginDisConnectedAction(this, m_Login); } } } m_Login = null; m_Game = null; if (m_ConnectionLogin != null) { m_ConnectionLogin.Dispose(); } m_ConnectionLogin = null; if (m_ConnectionGame != null) { m_ConnectionGame.Dispose(); } m_ConnectionGame = null; if (m_MatchedInfo != null) { m_MatchedInfo.Dispose(); } // PrintStatus("m_MatchedInfo Delete ID = {0}", m_LoginID); m_MatchedInfo = null; }
void HandleJoinGameRes(SFMessage message) { var Result = message.GetValue <Result>("Result"); if (Result.IsFailed) { PrintStatus(1, "JoinGameRes failed {0}", Result); CloseAllConnections(); return; } m_JoinedGameUID = message.GetValue <UInt64>("InsUID"); // if(m_JoinGameUID == 0) PrintStatus(1, "JoinGameRes Success GameID={0} MaxPlayer = {1} ID ={2}", m_JoinedGameUID, message.GetValue <uint>("MaxPlayer"), m_LoginID); m_MatchedInfo = new MatchedInfo(m_JoinedGameUID); }
// matching successed //-- 매칭 요청 완료시.. void HandleGameMatchedS2CEvt(SFMessage message) { if (m_Game == null) { return; } UInt64 GameInsID = message.GetValue <UInt64>("InsUID"); PrintStatus(1, "GameMatchedS2CEvt !! InsUID = {0} and JoinGameCmd!! ID = {1} ", GameInsID, m_LoginID); //m_Game.JoinGameCmd(m_AccountID, m_LoginTicket, GameInsID); //variableBuilder.SetVariable("InsUID", parser.GetInsUID()); //variableBuilder.SetVariable("TimeStamp", parser.GetTimeStamp()); //variableBuilder.SetVariable("GameState", (int)parser.GetGameState()); //variableBuilder.SetVariable("Day", parser.GetDay()); //variableBuilder.SetVariable("MaxPlayer", parser.GetMaxPlayer()); //variableBuilder.SetVariable("PlayerIndex", parser.GetPlayerIndex()); //variableBuilder.SetVariable("PlayerCharacter", parser.GetPlayerCharacter()); //variableBuilder.SetVariable("Role", (int)parser.GetRole()); //variableBuilder.SetVariable("Dead", parser.GetDead()); //variableBuilder.SetVariable("ChatHistoryData", (int)parser.GetChatHistoryData().size(), parser.GetChatHistoryData().data()); //variableBuilder.SetVariable("GameLogData", (int)parser.GetGameLogData().size(), parser.GetGameLogData().data()); //variableBuilder.SetVariable("Stamina", parser.GetStamina()); //variableBuilder.SetVariable("TotalGem", parser.GetTotalGem()); //variableBuilder.SetVariable("TotalGameMoney", parser.GetTotalGameMoney()); UInt64 JoinedGameUID = message.GetValue <UInt64>("InsUID"); if (m_JoinedGameUID == 0) { m_JoinedGameUID = JoinedGameUID; m_MatchedInfo = new MatchedInfo(m_JoinedGameUID); if (mReqMatchResAction != null) { mReqMatchResAction(this, true); } NextState = eTesterState.COMPLTE; } else if (JoinedGameUID == m_JoinedGameUID) { // Already has Joined!! } }
public void RunConnect(NetAddress serverAddress, System.Action <StressTest_MatchingUser> OnLoginConnected, System.Action <StressTest_MatchingUser, SF.Net.SendMessageLogin> OnLoginDisConnected, System.Action <StressTest_MatchingUser, int> OnLoginFailed, System.Action <StressTest_MatchingUser> OnGameSvrConnected, System.Action <StressTest_MatchingUser, SF.Net.SendMessageGame> OnGameSvrDisConnected, System.Action <StressTest_MatchingUser> OnGameSvrFailedConnect, System.Action <StressTest_MatchingUser, bool> OnGameJoinAction, System.Action <StressTest_MatchingUser> On4xMatchedAction, System.Action <StressTest_MatchingUser> OnSendMatchAction, System.Action <StressTest_MatchingUser, bool> OnReqMatchResAction, System.Action <StressTest_MatchingUser> OnRecvChatDataAction) { mLoginConnectedAction = OnLoginConnected; mLoginDisConnectedAction = OnLoginDisConnected; mLoginFailedAction = OnLoginFailed; // Game Sever mGameSvrConnectedAction = OnGameSvrConnected; mGameSvrDisConnectedAction = OnGameSvrDisConnected; mGameSvrFailedConnectAction = OnGameSvrFailedConnect; mGameJoinResAction = OnGameJoinAction; m4xMatchedAction = On4xMatchedAction; mSendReqMatchAction = OnSendMatchAction; mReqMatchResAction = OnReqMatchResAction; mRecvChatDataAction = OnRecvChatDataAction; m_MatchedInfo = new MatchedInfo(0); NextState = eTesterState.LOGINING; mCurDeltaTime = 0; m_ConnectionLogin = new SFConnection(m_MessageRouter); m_ConnectionLogin.Connect(0, serverAddress.Address, (int)serverAddress.Port); }
void HandleJoinGameServerRes(SFMessage message) { var joinResult = message.GetValue <Result>("Result"); if (joinResult.IsFailed) { if (mGameJoinResAction != null) { mGameJoinResAction(this, false); } PrintStatus(1, "Join game server failed {0}", joinResult); CloseAllConnections(); return; } else { if (mGameJoinResAction != null) { mGameJoinResAction(this, true); } } NextState = eTesterState.MATCHING; m_JoinedGameUID = message.GetValue <UInt64>("GameUID"); if (m_JoinedGameUID == 0) { if (mSendReqMatchAction != null) { mSendReqMatchAction(this); } } else { PrintStatus(1, "Already has JoinedGame!! = {0} ID = {1} And LeaveGameCMD!!", m_JoinedGameUID, m_LoginID); m_MatchedInfo = new MatchedInfo(m_JoinedGameUID); // Fixme //m_Game.LeaveGameCmd(0, m_JoinedGameUID, m_AccountID, m_LoginTicket); } }