本文整理汇总了PHP中raklib\Binary::readLong方法的典型用法代码示例。如果您正苦于以下问题:PHP Binary::readLong方法的具体用法?PHP Binary::readLong怎么用?PHP Binary::readLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raklib\Binary
的用法示例。
在下文中一共展示了Binary::readLong方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decode
public function decode()
{
parent::decode();
$this->clientID = Binary::readLong($this->get(8));
$this->sendPing = Binary::readLong($this->get(8));
$this->useSecurity = \ord($this->get(1)) > 0;
}
示例2: decode
public function decode()
{
parent::decode();
$this->clientID = Binary::readLong($this->get(8));
$this->session = Binary::readLong($this->get(8));
$this->unknown = $this->get(1);
}
示例3: decode
public function decode()
{
parent::decode();
$this->offset += 16;
//Magic
$this->getAddress($this->serverAddress, $this->serverPort);
$this->mtuSize = \unpack("n", $this->get(2))[1];
$this->clientID = Binary::readLong($this->get(8));
}
示例4: decode
public function decode()
{
parent::decode();
$this->pingID = Binary::readLong($this->get(8));
$this->serverID = Binary::readLong($this->get(8));
$this->offset += 16;
//magic
$this->serverName = $this->getString();
}
示例5: decode
public function decode()
{
parent::decode();
$this->offset += 16;
//Magic
$this->serverID = Binary::readLong($this->get(8));
\ord($this->get(1));
//security
$this->mtuSize = \unpack("n", $this->get(2))[1];
}
示例6: decode
public function decode()
{
parent::decode();
$this->offset += 16;
//Magic
$this->serverID = Binary::readLong($this->get(8));
$this->clientPort = unpack("n", $this->get(2))[1];
$this->mtuSize = unpack("n", $this->get(2))[1];
//server security
}
示例7: decode
public function decode()
{
parent::decode();
$this->getAddress($this->address, $this->port);
for ($i = 0; $i < 10; ++$i) {
$this->getAddress($addr, $port, $version);
$this->systemAddresses[$i] = [$addr, $port, $version];
}
$this->sendPing = Binary::readLong($this->get(8));
$this->sendPong = Binary::readLong($this->get(8));
}
示例8: decode
public function decode()
{
parent::decode();
$this->cookie = $this->get(4);
$this->security = $this->get(1);
$this->port = unpack("n", $this->get(2))[1];
$this->dataArray0 = $this->get(ord($this->get(1)));
$this->dataArray = $this->getDataArray(9);
$this->timestamp = $this->get(2);
$this->session2 = Binary::readLong($this->get(8));
$this->session = Binary::readLong($this->get(8));
}
示例9: decode
public function decode()
{
parent::decode();
$this->pingID = Binary::readLong($this->get(8));
}
示例10: handlePacket
/**
* @return bool
*/
public function handlePacket()
{
if (strlen($packet = $this->server->readThreadToMainPacket()) > 0) {
$id = ord($packet[0]);
$offset = 1;
if ($id === RakLib::PACKET_ENCAPSULATED) {
$len = ord($packet[$offset++]);
$identifier = substr($packet, $offset, $len);
$offset += $len;
$flags = ord($packet[$offset++]);
$buffer = substr($packet, $offset);
$this->instance->handleEncapsulated($identifier, EncapsulatedPacket::fromBinary($buffer, true), $flags);
} elseif ($id === RakLib::PACKET_RAW) {
$len = ord($packet[$offset++]);
$address = substr($packet, $offset, $len);
$offset += $len;
$port = unpack("n", substr($packet, $offset, 2))[1];
$offset += 2;
$payload = substr($packet, $offset);
$this->instance->handleRaw($address, $port, $payload);
} elseif ($id === RakLib::PACKET_SET_OPTION) {
$len = ord($packet[$offset++]);
$name = substr($packet, $offset, $len);
$offset += $len;
$value = substr($packet, $offset);
$this->instance->handleOption($name, $value);
} elseif ($id === RakLib::PACKET_OPEN_SESSION) {
$len = ord($packet[$offset++]);
$identifier = substr($packet, $offset, $len);
$offset += $len;
$len = ord($packet[$offset++]);
$address = substr($packet, $offset, $len);
$offset += $len;
$port = unpack("n", substr($packet, $offset, 2))[1];
$offset += 2;
$clientID = Binary::readLong(substr($packet, $offset, 8));
$this->instance->openSession($identifier, $address, $port, $clientID);
} elseif ($id === RakLib::PACKET_CLOSE_SESSION) {
$len = ord($packet[$offset++]);
$identifier = substr($packet, $offset, $len);
$offset += $len;
$len = ord($packet[$offset++]);
$reason = substr($packet, $offset, $len);
$this->instance->closeSession($identifier, $reason);
} elseif ($id === RakLib::PACKET_INVALID_SESSION) {
$len = ord($packet[$offset++]);
$identifier = substr($packet, $offset, $len);
$this->instance->closeSession($identifier, "Invalid session");
} elseif ($id === RakLib::PACKET_ACK_NOTIFICATION) {
$len = ord($packet[$offset++]);
$identifier = substr($packet, $offset, $len);
$offset += $len;
$identifierACK = PHP_INT_SIZE === 8 ? unpack("N", substr($packet, $offset, 4))[1] << 32 >> 32 : unpack("N", substr($packet, $offset, 4))[1];
$this->instance->notifyACK($identifier, $identifierACK);
}
return true;
}
return false;
}
示例11: getLong
protected function getLong($signed = \true)
{
return Binary::readLong($this->get(8), $signed);
}
示例12: handleEncapsulatedPacketRoute
protected function handleEncapsulatedPacketRoute(EncapsulatedPacket $packet)
{
if ($this->sessionManager === null) {
return;
}
$id = ord($packet->buffer[0]);
if ($id < 0x80) {
//internal data packet
if ($this->state === self::STATE_CONNECTING_2) {
if ($id === CLIENT_CONNECT_DataPacket::$ID) {
$dataPacket = new CLIENT_CONNECT_DataPacket();
$dataPacket->buffer = $packet->buffer;
$dataPacket->decode();
$pk = new SERVER_HANDSHAKE_DataPacket();
$pk->port = $this->port;
$pk->session = $dataPacket->session;
$pk->session2 = Binary::readLong("D\v©");
$pk->encode();
$sendPacket = new EncapsulatedPacket();
$sendPacket->reliability = 0;
$sendPacket->buffer = $pk->buffer;
$this->addToQueue($sendPacket, RakLib::PRIORITY_IMMEDIATE);
} elseif ($id === CLIENT_HANDSHAKE_DataPacket::$ID) {
$dataPacket = new CLIENT_HANDSHAKE_DataPacket();
$dataPacket->buffer = $packet->buffer;
$dataPacket->decode();
if ($dataPacket->port === $this->sessionManager->getPort() or !$this->sessionManager->portChecking) {
$this->state = self::STATE_CONNECTED;
//FINALLY!
$this->sessionManager->openSession($this);
foreach ($this->preJoinQueue as $p) {
$this->sessionManager->streamEncapsulated($this, $p);
}
$this->preJoinQueue = [];
}
}
} elseif ($id === CLIENT_DISCONNECT_DataPacket::$ID) {
$this->disconnect("client disconnect");
} elseif ($id === PING_DataPacket::$ID) {
$dataPacket = new PING_DataPacket();
$dataPacket->buffer = $packet->buffer;
$dataPacket->decode();
$pk = new PONG_DataPacket();
$pk->pingID = $dataPacket->pingID;
$pk->encode();
$sendPacket = new EncapsulatedPacket();
$sendPacket->reliability = 0;
$sendPacket->buffer = $pk->buffer;
$this->addToQueue($sendPacket);
}
//TODO: add PING/PONG (0x00/0x03) automatic latency measure
} elseif ($this->state === self::STATE_CONNECTED) {
$this->sessionManager->streamEncapsulated($this, $packet);
//TODO: split packet handling
//TODO: stream channels
} else {
$this->preJoinQueue[] = $packet;
}
}