1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Decode BatchPacket

Discussion in 'Development' started by alexwolf_dev, Oct 27, 2017.

  1. alexwolf_dev

    alexwolf_dev Spider Jockey

    Messages:
    43
    GitHub:
    Frago9876543210
    Hello. I wrote a simple proxy that read packets from the server and the client, but how decode batch?

    PHP:
    if(($packet Pool::getPacketFromPool(ord($buffer{0}))) !== null){
       
    $packet->buffer $buffer;
       
    $packet->decode();
       if(
    $packet instanceof DATA_PACKET_4){
          foreach(
    $packet->packets as $pk){
             
    $id ord($pk->buffer{0});
             if(
    $id !== 0x10 && $id !== 0x03){
                
    $dataPacket PacketPool::getPacket($pk->buffer);
                if(
    $dataPacket instanceof BatchPacket){
                   
    $dataPacket->decode();
                   
    var_dump($dataPacket); //need decode batch here
                
    }
             }
          }
       }
    }
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Use this to get every packet in a BatchPacket:
    PHP:
    if($dataPacket instanceof BatchPacket){
        
    $dataPacket->decode();
        foreach(
    $dataPacket->getPackets() as $buf){
            
    $pk PacketPool::getPacketById(ord($buf{0}));
            if(!
    $pk->canBeBatched()){
                continue;
            }
            
    $pk->setBuffer($buf1);
            
    //Now handle $pk like a normal Packet
        
    }
    }
    PS: I'm pretty bad at understanding the networking in pmmp, so this might be wrong.
     
    Last edited: Oct 27, 2017
    jasonwynn10 likes this.
  3. alexwolf_dev

    alexwolf_dev Spider Jockey

    Messages:
    43
    GitHub:
    Frago9876543210
    Warning: zlib_decode(): data error in BatchPacket.php on line 59 :confused:
     
  4. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    welp, maybe you got an invalid packet?
     
  5. alexwolf_dev

    alexwolf_dev Spider Jockey

    Messages:
    43
    GitHub:
    Frago9876543210
    Maybe. I got this
    Code:
    Warning: zlib_decode(): data error in \BatchPacket.php on line 59
    
    or this
    Code:
    object(Generator)#144 (0) {
    }
    
    when use
    PHP:
    var_dump($dataPacket->getPackets());
     
  6. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
  7. alexwolf_dev

    alexwolf_dev Spider Jockey

    Messages:
    43
    GitHub:
    Frago9876543210
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.