Ejemplo n.º 1
0
 /**
  * @param Stream $stream
  * @param string $topic
  * @param int $qos
  * @return \React\Promise\Promise
  */
 public function subscribe(Stream $stream, $topic, $qos = 0)
 {
     $deferred = new Deferred();
     $packet = new Subscribe($this->version);
     $packet->addSubscription($topic, $qos);
     $this->sentMessageToStream($stream, $packet);
     $deferred = new Deferred();
     $stream->on('SUBSCRIBE_ACK', function ($message) use($stream, $deferred) {
         $deferred->resolve($stream);
     });
     return $deferred->promise();
 }
Ejemplo n.º 2
0
 public function testGetControlPacketType()
 {
     $version = new \oliverlorenz\reactphpmqtt\protocol\Version4();
     $packet = new \oliverlorenz\reactphpmqtt\packet\Subscribe($version);
     $this->assertEquals(\oliverlorenz\reactphpmqtt\packet\Subscribe::getControlPacketType(), 8);
 }