Exemplo n.º 1
0
 public function testGetControlPacketType()
 {
     $version = new \oliverlorenz\reactphpmqtt\protocol\Version4();
     $packet = new \oliverlorenz\reactphpmqtt\packet\Connect($version);
     $this->assertEquals(1, \oliverlorenz\reactphpmqtt\packet\Connect::getControlPacketType());
 }
Exemplo n.º 2
0
 public function connect(Stream $stream, $username = null, $password = null, $clientId = null, $cleanSession = true, $willTopic = null, $willMessage = null, $willQos = null, $willRetain = null)
 {
     $packet = new Connect($this->version, $username, $password, $clientId, $cleanSession, $willTopic, $willMessage, $willQos, $willRetain);
     $message = $packet->get();
     echo MessageHelper::getReadableByRawString($message);
     $deferred = new Deferred();
     if ($stream->write($message)) {
         $deferred->resolve($stream);
     } else {
         $deferred->reject();
     }
     return $deferred->promise();
 }