echo 'Enough bytes, processing...' . "\n"; } //Awesome we have enough bytes now :D //Lets continue the "so waited" code part //Copy the 5+length first bytes from the buffer to $CAPSULE. $CAPSULE = new ByteArray(); $CAPSULE->append(substr($BUFFER->getBuffer(), 5, $length)); //position to 5 and read length bytes //PROCESS THE CAPSULE (switch and stuff) //----------------------------------------------- if ($VERBOSE) { echo 'Capsule: ' . $CAPSULE->getBuffer() . "\n"; } while (true) { //a loop to parse all CMDs in the capsule switch ($CAPSULE->readWord()) { //------------------------- case PCKT_R_WORLD_EOF: echo '[capsuleHandler] End of world server list' . "\n"; break; //------------------------- //------------------------- case PCKT_R_WORLD: echo '[capsuleHandler] New world server' . "\n"; $ipv4 = $CAPSULE->readString(); $port = $CAPSULE->readWord(); $name = $CAPSULE->readString(); $online = $CAPSULE->readBool(); $flag = $CAPSULE->readByte(); $status = $online ? 'online' : 'offline'; echo '-> (Flag ' . $flag . ') ' . $name . ' (' . $ipv4 . ':' . $port . ') is ' . $status . "\n";