Added hostname resolving

This commit is contained in:
Eduard Urbach 2024-02-26 16:03:40 +01:00
parent a097809c30
commit 88d04211fd
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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()