raklib\protocol\UNCONNECTED_PING::decode PHP Метод

decode() публичный Метод

public decode ( )
    public function decode()
    {
        parent::decode();
        $this->pingID = $this->getLong();
        //magic
    }

Usage Example

Пример #1
0
 private function receivePacket()
 {
     if (($len = $this->socket->readPacket($buffer, $source, $port)) > 0) {
         $this->receiveBytes += $len;
         if (isset($this->block[$source])) {
             return true;
         }
         if (isset($this->ipSec[$source])) {
             $this->ipSec[$source]++;
         } else {
             $this->ipSec[$source] = 1;
         }
         $pid = ord($buffer[0]);
         if (($packet = $this->getPacketFromPool($pid)) !== null) {
             $packet->buffer = $buffer;
             $this->getSession($source, $port)->handlePacket($packet);
             return true;
         } elseif ($pid === UNCONNECTED_PING::$ID) {
             //No need to create a session for just pings
             $packet = new UNCONNECTED_PING();
             $packet->buffer = $buffer;
             $packet->decode();
             $pk = new UNCONNECTED_PONG();
             $pk->serverID = $this->getID();
             $pk->pingID = $packet->pingID;
             $pk->serverName = $this->getName();
             $this->sendPacket($pk, $source, $port);
         } elseif ($buffer !== "") {
             $this->streamRaw($source, $port, $buffer);
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
UNCONNECTED_PING