src/Server/Asyn/MQTT/Message/Base.php
final public function build(&$length=0)
    {
        if ($this->protocol_type == self::FIXED_ONLY) {
            $payload = $this->payload();
        } else if ($this->protocol_type == self::WITH_VARIABLE) {
            $payload = $this->payload();
        } else if ($this->protocol_type == self::WITH_PAYLOAD) {
            $payload = $this->payload();
        } else {
            throw new Exception('Invalid protocol type');
        }

        $length = strlen($payload);
        $this->header->setPayloadLength($length);

        $length = $this->header->getFullLength();
        Debug::Log(Debug::DEBUG, 'Message Build: total length='.$length);

        return $this->header->build() . $payload;
    }
final public function build(&$length=0)
    {
        if ($this->protocol_type == self::FIXED_ONLY) {
            $payload = $this->payload();
        } else if ($this->protocol_type == self::WITH_VARIABLE) {
            $payload = $this->payload();
        } else if ($this->protocol_type == self::WITH_PAYLOAD) {
            $payload = $this->payload();
        } else {
            throw new Exception('Invalid protocol type');
        }

        $length = strlen($payload);
        $this->header->setPayloadLength($length);

        $length = $this->header->getFullLength();
        Debug::Log(Debug::DEBUG, 'Message Build: total length='.$length);

        return $this->header->build() . $payload;
    }
final public function build ( & $ length = 0 ) { if ( $ this -> protocol_type == self :: FIXED_ONLY ) { $ payload = $ this -> payload ( ) ; } else if ( $ this -> protocol_type == self :: WITH_VARIABLE ) { $ payload = $ this -> payload ( ) ; } else if ( $ this -> protocol_type == self :: WITH_PAYLOAD ) { $ payload = $ this -> payload ( ) ; } else { throw new Exception ( 'Invalid protocol type' ) ; } $ length = strlen ( $ payload ) ; $ this -> header -> setPayloadLength ( $ length ) ; $ length = $ this -> header -> getFullLength ( ) ; Debug :: Log ( Debug :: DEBUG , 'Message Build: total length=' . $ length ) ; return $ this -> header -> build ( ) . $ payload ; }
Build packet data

@param int & $length
@return string
@throws Exception
Build packet data