From 85b5ee7acddd2eab362902865903ca6ee7b43ea9 Mon Sep 17 00:00:00 2001 From: Dries C Date: Sat, 6 Apr 2024 00:10:07 +0100 Subject: [PATCH] Add support for the latest PMMP --- ProxyNetworkInterface.php | 6 +++++- ProxyPacketSender.php | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ProxyNetworkInterface.php b/ProxyNetworkInterface.php index ca926a0..5a005c6 100644 --- a/ProxyNetworkInterface.php +++ b/ProxyNetworkInterface.php @@ -274,7 +274,7 @@ public function getSession(int $socketId): ?NetworkSession return $this->sessions[$socketId] ?? null; } - public function putPacket(int $socketId, ProxyPacket $pk): void + public function putPacket(int $socketId, ProxyPacket $pk, int $receiptId = null): void { $serializer = new ProxyPacketSerializer(); $serializer->putLInt($socketId); @@ -289,6 +289,10 @@ public function putPacket(int $socketId, ProxyPacket $pk): void } catch (Error $exception) { $this->server->getLogger()->debug('Packet was send while the client was already shut down'); } + + if ($receiptId !== null) { // TODO: check if QUIC supports acks on specific data ;l + $this->getSession($socketId)?->handleAckReceipt($receiptId); + } } public function createSession(int $socketId, string $ip, int $port): NetworkSession diff --git a/ProxyPacketSender.php b/ProxyPacketSender.php index 7a98e1d..4f92b0d 100644 --- a/ProxyPacketSender.php +++ b/ProxyPacketSender.php @@ -26,13 +26,13 @@ public function __construct(int $socketId, ProxyNetworkInterface $handler) $this->handler = $handler; } - public function send(string $payload, bool $immediate): void + public function send(string $payload, bool $immediate, ?int $receiptId): void { if (!$this->closed) { $pk = new ForwardPacket(); $pk->payload = $payload; - $this->handler->putPacket($this->socketId, $pk); + $this->handler->putPacket($this->socketId, $pk, $receiptId); } }