20 lines
417 B
GDScript3
Raw Normal View History

2024-01-20 21:18:58 +00:00
extends NetworkNode
2024-01-25 11:10:29 +00:00
@export var host: String
@export var port: int
2024-01-20 21:18:58 +00:00
var socket := PacketPeerUDP.new()
2024-01-25 11:10:29 +00:00
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)
2024-01-20 21:18:58 +00:00
func _process(_delta):
while socket.get_available_packet_count() > 0:
var packet := socket.get_packet()
handle_packet(packet, socket)