public void ReceiveObject(LocalClient client, byte[] header) { int index = 2; E_CODE code = (E_CODE)Converter.GetShort(header, ref index); short subCode = Converter.GetShort(header, ref index); short gameCode = Converter.GetShort(header, ref index); short errorCode = Converter.GetShort(header, ref index); // 에러코드 if (errorCode == 1 || errorCode == 2) { Debug.LogError("Type " + (short)code + " ErrorCode : " + errorCode); } else { Debug.Log("Type " + (short)code + " Not Error"); } switch (code) // 유니티 단일 스레드 코루틴으로 패킷 처리 { case E_CODE.REEL_DATA: m_reelData = new Packet.OnRecvReelData(header); break; case E_CODE.SPIN_DATA: m_spinData = new Packet.OnRecvSpinData(header); break; case E_CODE.RECV_JOIN_GAME: m_joinGameData = new Packet.OnRecvJoinGame(header); break; case E_CODE.RECV_FREE_SPIN: m_freeSpinData = new Packet.OnRecvFreeSpin(header); break; case E_CODE.RECV_ROOM_DATA: m_roomData = new Packet.OnRecvRoomData(header); break; case E_CODE.RECV_ACCOUNT: m_accountData = new Packet.OnRecvAccount(header); break; case E_CODE.RECV_TEST_ACCOUNT: m_testAccountData = new Packet.OnRecvTestAccount(header); break; default: break; } }
IEnumerator SecondUpdate() // 서버 패킷 처리 { while (true) { //if (recvData && m_pingCorutine != null) // StopCoroutine(m_pingCorutine); if (m_bConnectServer) { GameManager.instance.m_isGame = true; m_lastGameCode = GameManager.instance.GameCode; if (!GameManager.instance.m_isDebug) { SendPacket(new Packet.OnAccount(GameManager.instance.GameCode, GameManager.instance.m_userId).Make()); } else { SendPacket(new Packet.OnTestAccount(GameManager.instance.GameCode).Make()); } m_bConnectServer = false; } if (m_testAccountData != null) // 5011 { Debug.Log("테스트 계정 받음"); GameManager.instance.m_userId = m_testAccountData.o_testeruserid; SendPacket(new Packet.OnAccount(GameManager.instance.GameCode, GameManager.instance.m_userId).Make()); m_testAccountData = null; } if (m_accountData != null) // 5001 { Debug.Log("로그인 데이터 받음"); SendPacket(new Packet.OnJoinGame(GameManager.instance.GameCode).Make()); // 두번째 인자 방 번호 GameManager.instance.m_totalMoney = m_accountData.o_totalcoin; m_accountData = null; } if (m_joinGameData != null) // 4001 { Debug.Log("게임 방 접속"); Debug.Log(GameManager.instance.GameCode + "---" + GameManager.instance.m_roomIndex); SendPacket(new Packet.OnRoomData(GameManager.instance.GameCode, GameManager.instance.m_roomIndex).Make()); StartCoroutine(Ping()); m_joinGameData = null; } if (m_roomData != null) // 4111 { Debug.Log("방 정보 확인"); SendPacket(new Packet.OnStart(GameManager.instance.GameCode, 1).Make()); m_roomData = null; } if (m_reelData != null) { Debug.Log("릴 데이터 받음"); GameManager.instance.SetReelData(m_reelData); m_reelData = null; } if (m_spinData != null) { Debug.Log("스핀 데이터 받음"); //m_pingCorutine = StartCoroutine(Ping()); ReelManager.instance.StopReel(m_spinData); GameManager.instance.SetUserDataToSpin(m_spinData); UIManager.instance.ShowSpinToCredit(); m_spinData = null; } if (m_freeSpinData != null) { Debug.Log("프리스핀 데이터 받음"); FreeSpinUI.instance.SetMultiple(m_freeSpinData); m_freeSpinData = null; } if (m_isQuit) { StartCoroutine(ReConnectServer()); yield break; } yield return(new WaitForSeconds(0.01f)); } }