Added thread safe packet handlers

This commit is contained in:
2024-02-28 12:14:27 +01:00
parent bfec08ff02
commit ded6f51c5d
4 changed files with 14 additions and 7 deletions

View File

@ -21,5 +21,9 @@ func handle_packet(packet: PackedByteArray):
push_warning("Unknown packet type %d" % type)
return
handler.handle_packet.call_deferred(packet.slice(1))
if handler.thread_safe:
handler.handle_packet(packet.slice(1))
else:
handler.handle_packet.call_deferred(packet.slice(1))
download += packet.size()

View File

@ -16,5 +16,7 @@ enum Packet {
@export var packet_type: Packet
var thread_safe: bool
func handle_packet(_data: PackedByteArray):
pass