public function setWill($topic, $message, $qosLevel = 0, $isRetained = false)
    {
        $this->assertValidString($topic, false);
        if ($topic === '') {
            throw new \InvalidArgumentException('The topic must not be empty.');
        }

        $this->assertValidStringLength($message, false);
        if ($message === '') {
            throw new \InvalidArgumentException('The message must not be empty.');
        }

        $this->assertValidQosLevel($qosLevel, false);

        $this->willTopic = $topic;
        $this->willMessage = $message;

        $this->flags |= 4;
        $this->flags |= ($qosLevel << 3);

        if ($isRetained) {
            $this->flags |= 32;
        } else {
            $this->flags &= ~32;
        }
    }
public function setWill($topic, $message, $qosLevel = 0, $isRetained = false)
    {
        $this->assertValidString($topic, false);
        if ($topic === '') {
            throw new \InvalidArgumentException('The topic must not be empty.');
        }

        $this->assertValidStringLength($message, false);
        if ($message === '') {
            throw new \InvalidArgumentException('The message must not be empty.');
        }

        $this->assertValidQosLevel($qosLevel, false);

        $this->willTopic = $topic;
        $this->willMessage = $message;

        $this->flags |= 4;
        $this->flags |= ($qosLevel << 3);

        if ($isRetained) {
            $this->flags |= 32;
        } else {
            $this->flags &= ~32;
        }
    }
public function setWill ( $ topic , $ message , $ qosLevel = 0 , $ isRetained = false ) { $ this -> assertValidString ( $ topic , false ) ; if ( $ topic === '' ) { throw new \ InvalidArgumentException ( 'The topic must not be empty.' ) ; } $ this -> assertValidStringLength ( $ message , false ) ; if ( $ message === '' ) { throw new \ InvalidArgumentException ( 'The message must not be empty.' ) ; } $ this -> assertValidQosLevel ( $ qosLevel , false ) ; $ this -> willTopic = $ topic ; $ this -> willMessage = $ message ; $ this -> flags |= 4 ; $ this -> flags |= ( $ qosLevel << 3 ) ; if ( $ isRetained ) { $ this -> flags |= 32 ; } else { $ this -> flags &= ~ 32 ; } }
Sets the will.

@param string $topic
@param string $message
@param int    $qosLevel
@param bool   $isRetained

@throws \InvalidArgumentException
Sets the will .