本文整理汇总了PHP中pocketmine\utils\Binary::writeLShort方法的典型用法代码示例。如果您正苦于以下问题:PHP Binary::writeLShort方法的具体用法?PHP Binary::writeLShort怎么用?PHP Binary::writeLShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\utils\Binary
的用法示例。
在下文中一共展示了Binary::writeLShort方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: putLShort
public function putLShort($v)
{
$this->buffer .= Binary::writeLShort($v);
}
示例2: putShort
public function putShort($v)
{
$this->buffer .= $this->endianness === self::BIG_ENDIAN ? Binary::writeShort($v) : Binary::writeLShort($v);
}
示例3: handle
public function handle($address, $port, $packet)
{
$offset = 2;
$packetType = ord($packet[$offset++]);
$sessionID = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$payload = substr($packet, $offset);
switch ($packetType) {
case self::HANDSHAKE:
//Handshake
$reply = chr(self::HANDSHAKE);
$reply .= Binary::writeInt($sessionID);
$reply .= self::getTokenString($this->token, $address) . "";
$this->server->sendPacket($address, $port, $reply);
break;
case self::STATISTICS:
//Stat
$token = Binary::readInt(substr($payload, 0, 4));
if ($token !== self::getTokenString($this->token, $address) and $token !== self::getTokenString($this->lastToken, $address)) {
break;
}
$reply = chr(self::STATISTICS);
$reply .= Binary::writeInt($sessionID);
if (strlen($payload) === 8) {
if ($this->timeout < microtime(true)) {
$this->regenerateInfo();
}
$reply .= $this->longData;
} else {
$reply .= $this->server->getServerName() . "" . (($this->server->getGamemode() & 0x1) === 0 ? "SMP" : "CMP") . "" . ($this->server->getDefaultLevel() === null ? "unknown" : $this->server->getDefaultLevel()->getName()) . "" . count($this->server->getOnlinePlayers()) . "" . $this->server->getMaxPlayers() . "" . Binary::writeLShort($this->server->getPort()) . $this->server->getIp() . "";
}
$this->server->sendPacket($address, $port, $reply);
break;
}
}
示例4: getShortQuery
public function getShortQuery()
{
return $this->serverName . "" . $this->gametype . "" . $this->map . "" . $this->numPlayers . "" . $this->maxPlayers . "" . Binary::writeLShort($this->port) . $this->ip . "";
}
示例5: putString
public function putString($string)
{
$this->buffer .= Binary::writeLShort(strlen($string));
$this->buffer .= $string;
}