15declare(strict_types=1);
17namespace raklib\server;
31 public const DEFAULT_MAX_SPLIT_PART_COUNT = 128;
32 public const DEFAULT_MAX_CONCURRENT_SPLIT_COUNT = 4;
35 private int $internalId;
37 public function __construct(
44 int $recvMaxSplitParts = self::DEFAULT_MAX_SPLIT_PART_COUNT,
45 int $recvMaxConcurrentSplits = self::DEFAULT_MAX_CONCURRENT_SPLIT_COUNT
47 $this->server = $server;
48 $this->internalId = $internalId;
49 parent::__construct($logger, $address, $clientId, $mtuSize, $recvMaxSplitParts, $recvMaxConcurrentSplits);
56 return $this->internalId;
60 $this->server->sendPacket($packet, $this->address);
64 $this->server->getEventListener()->onPacketAck($this->internalId, $identifierACK);
68 $this->server->getEventListener()->onClientDisconnect($this->internalId, $reason);
72 $id = ord($packet[0]);
73 if($id === MessageIdentifiers::ID_CONNECTION_REQUEST){
76 $this->queueConnectedPacket(ConnectionRequestAccepted::create(
79 $dataPacket->sendPingTime,
80 $this->getRakNetTimeMS()
81 ), PacketReliability::UNRELIABLE, 0,
true);
82 }elseif($id === MessageIdentifiers::ID_NEW_INCOMING_CONNECTION){
86 if($dataPacket->address->getPort() === $this->server->getPort() or !$this->server->portChecking){
87 $this->state = self::STATE_CONNECTED;
88 $this->server->openSession($this);
97 $this->server->getEventListener()->onPacketReceive($this->internalId, $packet);
101 $this->server->getEventListener()->onPingMeasure($this->internalId, $pingMS);
onDisconnect(int $reason)
onPingMeasure(int $pingMS)
onPacketAck(int $identifierACK)
handleRakNetConnectionPacket(string $packet)
onPacketReceive(string $packet)
sendPacket(Packet $packet)