gate is not responding

This commit is contained in:
Nordup 2024-10-26 03:58:13 +04:00
parent 83406350c0
commit 4fc2d7aeb9
7 changed files with 77 additions and 19 deletions

View file

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

View file

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

View file

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