2024-01-25 12:10:29 +01:00

20 lines
417 B
GDScript

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