29 public function __construct(
33 public function sendEncapsulated(
int $sessionId,
EncapsulatedPacket $packet,
bool $immediate =
false) :
void{
35 ($immediate ? ITCProtocol::ENCAPSULATED_FLAG_IMMEDIATE : 0) |
36 ($packet->identifierACK !==
null ? ITCProtocol::ENCAPSULATED_FLAG_NEED_ACK : 0);
38 $buffer = chr(ITCProtocol::PACKET_ENCAPSULATED) .
39 Binary::writeInt($sessionId) .
41 chr($packet->reliability) .
42 ($packet->identifierACK !==
null ? Binary::writeInt($packet->identifierACK) :
"") .
43 (PacketReliability::isSequencedOrOrdered($packet->reliability) ? chr($packet->orderChannel) :
"") .
45 $this->channel->write($buffer);
48 public function sendRaw(
string $address,
int $port,
string $payload) :
void{
49 $buffer = chr(ITCProtocol::PACKET_RAW) . chr(strlen($address)) . $address . Binary::writeShort($port) . $payload;
50 $this->channel->write($buffer);
53 public function closeSession(
int $sessionId) :
void{
54 $buffer = chr(ITCProtocol::PACKET_CLOSE_SESSION) . Binary::writeInt($sessionId);
55 $this->channel->write($buffer);
58 public function setName(
string $name) :
void{
59 $this->channel->write(chr(ITCProtocol::PACKET_SET_NAME) . $name);
62 public function setPortCheck(
bool $value) :
void{
63 $this->channel->write(chr($value ? ITCProtocol::PACKET_ENABLE_PORT_CHECK : ITCProtocol::PACKET_DISABLE_PORT_CHECK));
66 public function setPacketsPerTickLimit(
int $limit) :
void{
67 $this->channel->write(chr(ITCProtocol::PACKET_SET_PACKETS_PER_TICK_LIMIT) . Binary::writeLong($limit));
70 public function blockAddress(
string $address,
int $timeout) :
void{
71 $buffer = chr(ITCProtocol::PACKET_BLOCK_ADDRESS) . chr(strlen($address)) . $address . Binary::writeInt($timeout);
72 $this->channel->write($buffer);
75 public function unblockAddress(
string $address) :
void{
76 $buffer = chr(ITCProtocol::PACKET_UNBLOCK_ADDRESS) . chr(strlen($address)) . $address;
77 $this->channel->write($buffer);
80 public function addRawPacketFilter(
string $regex) :
void{
81 $this->channel->write(chr(ITCProtocol::PACKET_RAW_FILTER) . $regex);