If the total packet size is larger than 1024, then it is splitted into subpackets

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
2020-12-21 16:04:13 +01:00
parent bda4860aca
commit b96ff488e7
2 changed files with 40 additions and 9 deletions

View File

@@ -75,6 +75,9 @@ class Squirrel(Hazelnut):
"""
Send a formatted packet to a client.
"""
if len(pkt) > 1024:
# The packet is too large to be sent by the protocol. We split the packet in subpackets.
return sum(self.send_packet(client, subpkt) for subpkt in pkt.split(1024))
return self.send_raw_data(client, pkt.marshal())
def send_raw_data(self, client: Hazelnut, data: bytes) -> int: