From 88d04211fd588028973591a0e766bb6a280d13a6 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 26 Feb 2024 16:03:40 +0100 Subject: [PATCH] Added hostname resolving --- client/Main.tscn | 1 + client/network/Client.gd | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/Main.tscn b/client/Main.tscn index 26f58b8..d8df03b 100644 --- a/client/Main.tscn +++ b/client/Main.tscn @@ -28,6 +28,7 @@ process_thread_group = 2 process_thread_group_order = 0 process_thread_messages = 0 script = ExtResource("2_8hxcx") +host = "akyoto.dev" [node name="Ping" type="Node" parent="Client"] unique_name_in_owner = true diff --git a/client/network/Client.gd b/client/network/Client.gd index 4097048..04fdebc 100644 --- a/client/network/Client.gd +++ b/client/network/Client.gd @@ -1,6 +1,6 @@ extends NetworkNode -@export var host := "127.0.0.1" +@export var host := "localhost" @export var port := 4242 signal download_changed(down: int) @@ -10,14 +10,16 @@ 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 _ready(): + var ip := IP.resolve_hostname(host) + socket.connect_to_host(ip, port) + func _process(_delta): while socket.get_available_packet_count() > 0: var packet := socket.get_packet()