Example #1
0
    public void ConnectToServerRequest(string name)
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.CONNECTTOSERVER;
        ConnectToServer connectToServer = new ConnectToServer();

        connectToServer.name = name;
        req.connectToServer  = connectToServer;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Example #2
0
    public void flushRoomListRequest()
    {
        ProtocolNetRequest req = new ProtocolNetRequest();

        req.cmd = (int)NetRequestType.GETROOMLIST;
        GetRoomList getRoomList = new GetRoomList();

        getRoomList.fd  = GameGlobalData.fd;
        req.getRoomList = getRoomList;
        socket.sendMSG(PBCSerialize.Serialize(req));
    }
Example #3
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);
     }
 }