From a22381eff3bf2286ee27f4d15ddf4c431ea063be Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 12 Dec 2024 02:12:52 +0100 Subject: next commit --- network/server.gd | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'network/server.gd') diff --git a/network/server.gd b/network/server.gd index e46e797..8b41b4f 100644 --- a/network/server.gd +++ b/network/server.gd @@ -35,10 +35,27 @@ func listen() -> void: raw_packet += packet_length raw_packet += peer.get_data(packet_length.decode_u16(0) - 4)[1] + prints("Upcoming Length:", packet_length.decode_u16(0), "for =>") var packet = packet_type.from_bytes(raw_packet) received_packet.emit(packet) + + var display_header = raw_packet.slice(0, 2) + display_header.reverse() + print("Received known packet with header ", display_header.hex_encode(), " = ", packet_type.get_global_name()) else: raw_packet.reverse() print("Received unknown packet with header ", raw_packet.hex_encode()) + + +func send(packet: Packet) -> Error: + var display_header = packet.get_header() + display_header.reverse() + print("Sent packet with header ", display_header.hex_encode()) + + return send_raw(packet.to_bytes()) + + +func send_raw(bytes: PackedByteArray) -> Error: + return peer.put_data(bytes) -- cgit v1.2.3