extends NetworkNode @export var host: String @export var port: int 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, socket) 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()