示例#1
0
    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;
        }
    }
示例#2
0
 public void tick()
 {
     if (queue.Count > 0)
     {
         ProtocolNetResponse resp = queue.Dequeue();
         dealPbcMessage(resp);
     }
 }
示例#3
0
    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;
        }
    }
示例#4
0
 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);
     }
 }
示例#5
0
 public void getConnectToServerResponse(ProtocolNetResponse resp)
 {
     GameGlobalData.fd = resp.connectToServerResponse.fd;
     SceneManager.LoadScene("MainScene");
 }
示例#6
0
    public void changeBytes(byte[] bytes)
    {
        ProtocolNetResponse resp = PBCSerialize.Deserialize <ProtocolNetResponse>(bytes);

        Push(resp);
    }
示例#7
0
 public void Push(ProtocolNetResponse resp)
 {
     queue.Enqueue(resp);
 }