diff --git a/hamncheese/Scripts/edge.gd b/hamncheese/Scripts/edge.gd index 03b68d4..e62f8df 100644 --- a/hamncheese/Scripts/edge.gd +++ b/hamncheese/Scripts/edge.gd @@ -40,6 +40,7 @@ var _supernode := "" var _super_port := 0 var _local_port := 0 var _local_ip := "" +var _kill_timer := 10 signal data_recieved(type: String, data: Array) @@ -48,6 +49,7 @@ signal network_died func _on_timer_timeout(): if _edge_running: + _kill_timer = 10 if _udp.is_socket_connected(): _send("info") _send("edges") @@ -55,10 +57,14 @@ func _on_timer_timeout(): _udp.bind(_my_port, "127.0.0.1") _udp.connect_to_host("127.0.0.1", _management_port) else: - if _edge_pid >= 0: - if OS.is_process_running(_edge_pid): - OS.kill(_edge_pid) - _edge_pid = -1 + if _kill_timer > 0: + _kill_timer -= 1 + else: + if _edge_pid >= 0: + if OS.is_process_running(_edge_pid): + print("Timer killing edge pid ", _edge_pid) + OS.kill(_edge_pid) + _edge_pid = -1 func _process(_delta): @@ -125,10 +131,6 @@ func shutdown(): func start_edge(): - _timer = Timer.new() - _timer.wait_time = 3 - _timer.autostart = true - _timer.timeout.connect(_on_timer_timeout) var binary = OS.get_user_data_dir() + "/edge" var arguments = ["-t", _management_port, "--management-password", _password, "-c", _community, "-k", _key, "-l", _supernode + ":" + str(_super_port), "-p"] if _local_ip != "": @@ -150,6 +152,10 @@ func start_edge(): func startup(): + _timer = Timer.new() + _timer.wait_time = 3 + _timer.autostart = true + _timer.timeout.connect(_on_timer_timeout) # Extract the edge binary. var binary = OS.get_user_data_dir() + "/edge" if OS.get_name() == "Windows": @@ -163,8 +169,6 @@ func startup(): func stop_edge(): - if _timer != null: - _timer.queue_free() _send("stop", MODE_WRITE) _udp.close() _edge_running = false diff --git a/hamncheese/Scripts/peers.gd b/hamncheese/Scripts/peers.gd index 59b1500..be8efca 100644 --- a/hamncheese/Scripts/peers.gd +++ b/hamncheese/Scripts/peers.gd @@ -112,8 +112,8 @@ func _tcp_server(): peer["tcp"] = new_peer print("Updated peer ", peer["ip"], ":", peer["port"]) peer["tcp"].poll() - if peer["tcp"].get_status() == StreamPeerTCP.STATUS_CONNECTED: - peer["tcp"].set_no_delay(true) # ***TODO*** This throws an error some times. + #if peer["tcp"].get_status() == StreamPeerTCP.STATUS_CONNECTED: + # peer["tcp"].set_no_delay(true) # ***TODO*** This throws an error some times. # Process incoming data and attempt connections. for peer in peerArray: