connect timeout

This commit is contained in:
Nordup 2023-07-03 01:41:06 +04:00
parent e379e80711
commit 1b057ca571
4 changed files with 7 additions and 5 deletions

View file

@ -51,7 +51,6 @@ theme_override_font_sizes/font_size = 20
theme_override_styles/normal = SubResource("StyleBoxFlat_hyysn")
theme_override_styles/focus = SubResource("StyleBoxFlat_hyysn")
placeholder_text = "Search or enter address"
select_all_on_focus = true
script = ExtResource("1_7ivk2")
gate_events = ExtResource("2_13io8")

View file

@ -278,6 +278,7 @@ command_events = ExtResource("6_18mgg")
[node name="GateLoader" type="Node" parent="."]
script = ExtResource("1_uxhy6")
gate_events = ExtResource("2_q7cvi")
connect_timeout = 10.0
[node name="SandboxManager" type="Node" parent="." node_paths=PackedStringArray("render_result")]
script = ExtResource("3_0cpfc")

View file

@ -22,7 +22,7 @@ func _ready() -> void:
FileTools.remove_recursive(DOWNLOAD_FOLDER)
func download(url: String) -> String:
func download(url: String, timeout: float = 0) -> String:
var save_path = DOWNLOAD_FOLDER + "/" + url.md5_text() + "." + url.get_file().get_extension()
if FileAccess.file_exists(save_path):
@ -30,7 +30,7 @@ func download(url: String) -> String:
return save_path
DirAccess.make_dir_recursive_absolute(save_path.get_base_dir())
var result = await create_request(url, save_path)
var result = await create_request(url, save_path, timeout)
if result == 200:
return save_path
@ -58,10 +58,11 @@ func download_shared_lib(url: String, gate_url: String) -> String:
return ""
func create_request(url: String, save_path: String) -> int:
func create_request(url: String, save_path: String, timeout: float = 0) -> int:
var http = HTTPRequest.new()
http.download_file = save_path
http.use_threads = true
http.timeout = timeout
add_child(http)
var timer = create_progress_emitter(url, http)

View file

@ -1,6 +1,7 @@
extends Node
@export var gate_events: GateEvents
@export var connect_timeout: float
var c_gate: ConfigGate
@ -12,7 +13,7 @@ func _ready() -> void:
func load_gate(config_url: String) -> void:
Debug.logclr("======== " + config_url + " ========", Color.GREEN)
var config_path = await FileDownloader.download(config_url)
var config_path = await FileDownloader.download(config_url, connect_timeout)
if config_path.is_empty(): return error(GateEvents.GateError.NOT_FOUND)
c_gate = ConfigGate.new(config_path, config_url)