Added hostname resolving
This commit is contained in:
parent
a097809c30
commit
88d04211fd
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user