Пример #1
0
 public function write(PacketStream $stream)
 {
     if ($this->clientID === '') {
         $this->clientID = 'BinSoul' . mt_rand(100000, 999999);
     }
     $data = new PacketStream();
     $data->writeString($this->protocolName);
     $data->writeByte($this->protocolLevel);
     $data->writeByte($this->flags);
     $data->writeWord($this->keepAlive);
     $data->writeString($this->clientID);
     if ($this->hasWill()) {
         $data->writeString($this->willTopic);
         $data->writeString($this->willMessage);
     }
     if ($this->hasUsername()) {
         $data->writeString($this->username);
     }
     if ($this->hasPassword()) {
         $data->writeString($this->password);
     }
     $this->remainingPacketLength = $data->length();
     parent::write($stream);
     $stream->write($data->getData());
 }
Пример #2
0
 public function write(PacketStream $stream)
 {
     $this->remainingPacketLength = 2;
     parent::write($stream);
     $stream->writeByte($this->flags);
     $stream->writeByte($this->returnCode);
 }
Пример #3
0
 public function write(PacketStream $stream)
 {
     $data = new PacketStream();
     $data->writeWord($this->generateIdentifier());
     $data->writeString($this->topic);
     $this->remainingPacketLength = $data->length();
     parent::write($stream);
     $stream->write($data->getData());
 }
Пример #4
0
 public function write(PacketStream $stream)
 {
     $data = new PacketStream();
     $data->writeWord($this->generateIdentifier());
     foreach ($this->returnCodes as $returnCode) {
         $data->writeByte($returnCode);
     }
     $this->remainingPacketLength = $data->length();
     parent::write($stream);
     $stream->write($data->getData());
 }
Пример #5
0
 public function read(PacketStream $stream)
 {
     parent::read($stream);
     $this->assertPacketFlags(0);
     $this->assertRemainingPacketLength(0);
 }
Пример #6
0
 public function write(PacketStream $stream)
 {
     $this->remainingPacketLength = 2;
     parent::write($stream);
     $stream->writeWord($this->generateIdentifier());
 }