extends NetworkNode @export var host := "127.0.0.1" @export var port := 4242 signal download_changed(down: int) signal upload_changed(up: int) var socket := PacketPeerUDP.new() var upload := 0 func _enter_tree(): socket.connect_to_host(host, port) for child in get_children(): if !(child is PacketHandler): continue set_handler(child.packet_type, child) func _process(_delta): while socket.get_available_packet_count() > 0: var packet := socket.get_packet() handle_packet(packet) func update_statistics(): download_changed.emit(download) upload_changed.emit(upload) download = 0 upload = 0 func send(data: PackedByteArray): socket.put_packet(data) upload += data.size()