From 4fc2d7aeb9bd5246c26228febdb5faa8049de1a5 Mon Sep 17 00:00:00 2001 From: Nordup Date: Sat, 26 Oct 2024 03:58:13 +0400 Subject: [PATCH] gate is not responding --- app/scenes/menu_body/world.tscn | 30 +++++++++++++--------- app/scripts/resources/command_events.gd | 5 ++++ app/scripts/resources/gate_events.gd | 5 ++++ app/scripts/sandbox/command_sync.gd | 12 +++++++-- app/scripts/sandbox/input_sync.gd | 8 +++--- app/scripts/sandbox/process_checker.gd | 34 +++++++++++++++++++++++++ godot | 2 +- 7 files changed, 77 insertions(+), 19 deletions(-) create mode 100644 app/scripts/sandbox/process_checker.gd diff --git a/app/scenes/menu_body/world.tscn b/app/scenes/menu_body/world.tscn index cecca50..edaa360 100644 --- a/app/scenes/menu_body/world.tscn +++ b/app/scenes/menu_body/world.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=33 format=3 uid="uid://kywrsqro3d5i"] +[gd_scene load_steps=34 format=3 uid="uid://kywrsqro3d5i"] [ext_resource type="Script" path="res://scripts/loading/gate_loader.gd" id="1_uxhy6"] [ext_resource type="Resource" uid="uid://b1xvdym0qh6td" path="res://resources/gate_events.res" id="2_q7cvi"] @@ -13,6 +13,7 @@ [ext_resource type="Shader" path="res://shaders/render_result.gdshader" id="10_2auwe"] [ext_resource type="Texture2D" uid="uid://cykx425p6ylwr" path="res://assets/textures/background.png" id="10_23bjc"] [ext_resource type="Script" path="res://scripts/sandbox/command_sync.gd" id="10_cqo55"] +[ext_resource type="Script" path="res://scripts/sandbox/process_checker.gd" id="11_72cjp"] [ext_resource type="Script" path="res://scripts/ui/world/world_ui.gd" id="12_jdwjt"] [ext_resource type="Script" path="res://scripts/ui/world/splash_screen.gd" id="13_3b6nd"] [ext_resource type="Script" path="res://scripts/ui/world/gate_info.gd" id="14_8hca5"] @@ -305,6 +306,22 @@ render_result = NodePath("../HBoxContainer/WorldCanvas/RenderResult") snbx_executable = ExtResource("4_shus3") snbx_env = ExtResource("8_a6dvr") +[node name="InputSync" type="Node" parent="." node_paths=PackedStringArray("render_result")] +script = ExtResource("8_1blsi") +gate_events = ExtResource("2_q7cvi") +ui_events = ExtResource("9_ir58h") +render_result = NodePath("../HBoxContainer/WorldCanvas/RenderResult") + +[node name="CommandSync" type="CommandSync" parent="."] +script = ExtResource("10_cqo55") +gate_events = ExtResource("2_q7cvi") +command_events = ExtResource("6_18mgg") + +[node name="ProcessChecker" type="Node" parent="."] +script = ExtResource("11_72cjp") +gate_events = ExtResource("2_q7cvi") +command_events = ExtResource("6_18mgg") + [node name="HBoxContainer" type="HBoxContainer" parent="."] custom_minimum_size = Vector2(0, 700) layout_mode = 1 @@ -366,17 +383,6 @@ grow_horizontal = 2 grow_vertical = 2 focus_mode = 0 -[node name="InputSync" type="Node" parent="HBoxContainer/WorldCanvas" node_paths=PackedStringArray("render_result")] -script = ExtResource("8_1blsi") -gate_events = ExtResource("2_q7cvi") -ui_events = ExtResource("9_ir58h") -render_result = NodePath("../RenderResult") - -[node name="CommandSync" type="CommandSync" parent="HBoxContainer/WorldCanvas"] -script = ExtResource("10_cqo55") -gate_events = ExtResource("2_q7cvi") -command_events = ExtResource("6_18mgg") - [node name="Spacing" type="Control" parent="HBoxContainer"] custom_minimum_size = Vector2(50, 0) layout_mode = 2 diff --git a/app/scripts/resources/command_events.gd b/app/scripts/resources/command_events.gd index a57d900..3339c09 100644 --- a/app/scripts/resources/command_events.gd +++ b/app/scripts/resources/command_events.gd @@ -4,6 +4,7 @@ class_name CommandEvents signal send_filehandle(filehandle_path: String) signal ext_texture_format(format: RenderingDevice.DataFormat) signal set_mouse_mode(mode: int) +signal heartbeat() func send_filehandle_emit(filehandle_path: String) -> void: @@ -16,3 +17,7 @@ func ext_texture_format_emit(format: RenderingDevice.DataFormat) -> void: func set_mouse_mode_emit(mode: int) -> void: set_mouse_mode.emit(mode) + + +func heartbeat_emit() -> void: + heartbeat.emit() diff --git a/app/scripts/resources/gate_events.gd b/app/scripts/resources/gate_events.gd index 0ac24cd..877e2b2 100644 --- a/app/scripts/resources/gate_events.gd +++ b/app/scripts/resources/gate_events.gd @@ -8,6 +8,7 @@ signal gate_info_loaded(gate: Gate, is_cached: bool) signal gate_loaded(gate: Gate) signal gate_entered signal first_frame +signal not_responding signal exit_gate signal download_progress(url: String, body_size: int, downloaded_bytes: int) @@ -62,6 +63,10 @@ func first_frame_emit() -> void: first_frame.emit() +func not_responding_emit() -> void: + not_responding.emit() + + func exit_gate_emit() -> void: current_search_query = "" current_gate_url = "" diff --git a/app/scripts/sandbox/command_sync.gd b/app/scripts/sandbox/command_sync.gd index eeae77b..918aec7 100644 --- a/app/scripts/sandbox/command_sync.gd +++ b/app/scripts/sandbox/command_sync.gd @@ -3,6 +3,8 @@ extends CommandSync @export var gate_events: GateEvents @export var command_events: CommandEvents +var silent_commands = ["heartbeat"] + func _ready() -> void: gate_events.gate_entered.connect(bind) @@ -14,7 +16,9 @@ func _physics_process(_delta: float) -> void: func _execute_function(command: Command) -> Variant: - Debug.logclr("Recieved command: " + command.name + ". Args: " + str(command.args), Color.SANDY_BROWN) + if command.name not in silent_commands: + Debug.logclr("Recieved command: " + command.name + ". Args: " + str(command.args), Color.SANDY_BROWN) + match command.name: "send_filehandle": if wrong_args_count(command, 1): return ERR_INVALID_PARAMETER @@ -24,10 +28,14 @@ func _execute_function(command: Command) -> Variant: if wrong_args_count(command, 1): return ERR_INVALID_PARAMETER command_events.ext_texture_format_emit(command.args[0]) - "first_frame_drawn": + "first_frame": if wrong_args_count(command, 0): return ERR_INVALID_PARAMETER gate_events.first_frame_emit() + "heartbeat": + if wrong_args_count(command, 0): return ERR_INVALID_PARAMETER + command_events.heartbeat_emit() + "set_mouse_mode": if wrong_args_count(command, 1): return ERR_INVALID_PARAMETER command_events.set_mouse_mode_emit(command.args[0]) diff --git a/app/scripts/sandbox/input_sync.gd b/app/scripts/sandbox/input_sync.gd index dc0b464..8ba18d3 100644 --- a/app/scripts/sandbox/input_sync.gd +++ b/app/scripts/sandbox/input_sync.gd @@ -14,15 +14,15 @@ var should_send := false func _ready() -> void: gate_events.gate_entered.connect(start_server) ui_events.ui_mode_changed.connect(on_ui_mode_changed) - - scale_width = float(render_result.width) / ui_events.current_ui_size.x - scale_height = float(render_result.height) / ui_events.current_ui_size.y - Debug.logclr("Mouse position scale: %.2fx%.2f" % [scale_width, scale_height], Color.DIM_GRAY) func start_server() -> void: input_sync = InputSync.new() input_sync.bind() + + scale_width = float(render_result.width) / ui_events.current_ui_size.x + scale_height = float(render_result.height) / ui_events.current_ui_size.y + Debug.logclr("Mouse position scale: %.2fx%.2f" % [scale_width, scale_height], Color.DIM_GRAY) func on_ui_mode_changed(mode: UiEvents.UiMode) -> void: diff --git a/app/scripts/sandbox/process_checker.gd b/app/scripts/sandbox/process_checker.gd new file mode 100644 index 0000000..c84bb68 --- /dev/null +++ b/app/scripts/sandbox/process_checker.gd @@ -0,0 +1,34 @@ +extends Node + +@export var gate_events: GateEvents +@export var command_events: CommandEvents + +# Timeout interval for child process responsiveness +const BOOTUP_INTERVAL = 30 +const HEARTBEAT_INTERVAL = 5 +const WAIT_INTERVAL = 30 + +var timer: Timer + + +func _ready() -> void: + timer = Timer.new() + add_child(timer) + timer.timeout.connect(on_timeout) + + gate_events.gate_entered.connect(start_bootup_timer) + command_events.heartbeat.connect(restart_heartbeat_timer) + + +func start_bootup_timer() -> void: + timer.start(BOOTUP_INTERVAL) + + +func restart_heartbeat_timer() -> void: + timer.start(HEARTBEAT_INTERVAL) + + +func on_timeout() -> void: + Debug.logerr("Gate is not responding") + gate_events.not_responding_emit() + timer.start(WAIT_INTERVAL) diff --git a/godot b/godot index f51caa6..8fa7f8d 160000 --- a/godot +++ b/godot @@ -1 +1 @@ -Subproject commit f51caa6d0deba8abd21e7ccaf09ad1edbca604c1 +Subproject commit 8fa7f8db356dd32f8a8404cadab8d3980c05516c