public void ReceiveResponseData(ProtocolNetResponse resp) { switch (resp.cmd) { case (int)NetRequestType.PLAYERGAMEDATA: //Debug.Log("GameLogicResponse size:" + resp.playerGameDataResponse.data.Length); //GameLogicResponse response = PBCSerialize.Deserialize<GameLogicResponse>(resp.playerGameDataResponse.data); //switch ((GameSceneDataType)response.type) { // case GameSceneDataType.OtherOneTransform: // case GameSceneDataType.OtherOneAction: // case GameSceneDataType.OtherOneState: // ForwardList.Add(response); // break; // case GameSceneDataType.Response: // GenerateAverDelayTime(); // isReceiveData = true; // break; //} break; case (int)NetRequestType.GAMERESULT: break; case (int)NetRequestType.PLAYERRELOADSCENE: StartNetSend = false; UdpTick = false; SceneManager.LoadScene("ReloadScene"); break; } }
public void tick() { if (queue.Count > 0) { ProtocolNetResponse resp = queue.Dequeue(); dealPbcMessage(resp); } }
public void getPbcResponse(ProtocolNetResponse resp) { switch (resp.cmd) { case (int)NetRequestType.CREATEROOM: if (resp.createRoomResponse.result) { organizePanelEvent.gameObject.SetActive(false); roomPanelEvent.gameObject.SetActive(true); roomPanelEvent.roomOwnerSetData(roomOwner, GameGlobalData.fd, roomName, currentMan, maxManCount); type.text = "组队界面"; needFlush = false; } break; case (int)NetRequestType.GETROOMLIST: if (resp.getRoomListResponse.result) { organizePanelEvent.GenerateRoomList(resp.getRoomListResponse); } break; case (int)NetRequestType.JOINROOM: organizePanelEvent.gameObject.SetActive(false); roomPanelEvent.gameObject.SetActive(true); needFlush = false; type.text = "组队界面"; roomPanelEvent.PlayerJoinRoom(resp.joinRoomResponse); break; case (int)NetRequestType.EXITROOM: break; case (int)NetRequestType.ROOMOWNEREXIT: break; case (int)NetRequestType.ROOMOWNERREADYSTARTGAME: roomPanelEvent.serverAcceptStartGame(resp.roomOwnerReadyStartGameResponse); break; case (int)NetRequestType.ROOMOWNERSTARTGAME: roomPanelEvent.startGameInit(resp.roomOwnerStartGameResponse); break; } }
void dealPbcMessage(ProtocolNetResponse resp) { if (resp.cmd == (int)NetRequestType.HEARTBEAT) { ProtocolNetRequest req = new ProtocolNetRequest(); req.cmd = (int)NetRequestType.HEARTBEAT; socket.sendMSG(PBCSerialize.Serialize(req)); } else if (resp.cmd == (int)NetRequestType.FORECEEXITGAME) { Debug.Log("服务器已断开连接,强制退出游戏"); Application.Quit(); } else { callback(resp); } }
public void getConnectToServerResponse(ProtocolNetResponse resp) { GameGlobalData.fd = resp.connectToServerResponse.fd; SceneManager.LoadScene("MainScene"); }
public void changeBytes(byte[] bytes) { ProtocolNetResponse resp = PBCSerialize.Deserialize <ProtocolNetResponse>(bytes); Push(resp); }
public void Push(ProtocolNetResponse resp) { queue.Enqueue(resp); }