Adapt game clients to the unified WebSocket input stream.

Replace separate accel/tap push handling with input messages, set_input_stream, and a single set_stream on port 8081.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-31 13:47:41 +02:00
co-authored by Cursor
parent 440b49c889
commit 70e66f4d60
7 changed files with 219 additions and 268 deletions
+12 -10
View File
@@ -62,7 +62,7 @@ func _send(payload: Dictionary) -> void:
func _cleanup_streams() -> void:
if _socket.get_ready_state() != WebSocketPeer.STATE_OPEN:
return
_send({"type": "set_tap_stream", "enable": false, "interval_ms": STREAM_INTERVAL_MS})
_send({"type": "set_stream", "enable": false, "interval_ms": STREAM_INTERVAL_MS})
for cid in _pod_ids:
_send({
"type": "set_tap_notify",
@@ -106,8 +106,8 @@ func _handle_message(text: String) -> void:
_send({"type": "list_clients"})
"client_list":
_on_client_list(data)
"tap":
_on_tap(data)
"input":
_on_input(data)
func _on_client_list(data: Dictionary) -> void:
@@ -155,7 +155,7 @@ func _start_round() -> void:
for cid in _pod_ids:
_send_led_digit(cid, int(_pod_digits[cid]))
_enable_tap_stream()
_enable_input_stream()
_round_start_ms = Time.get_ticks_msec()
_set_phase(Phase.PLAYING, "%d Pods bereit" % _pod_ids.size())
target_label.text = str(_target_digit)
@@ -164,7 +164,7 @@ func _start_round() -> void:
hint_label.text = ""
func _enable_tap_stream() -> void:
func _enable_input_stream() -> void:
for cid in _pod_ids:
_send({
"type": "set_tap_notify",
@@ -173,17 +173,19 @@ func _enable_tap_stream() -> void:
"double_tap": false,
"triple": false,
})
_send({"type": "set_tap_stream", "enable": true, "interval_ms": STREAM_INTERVAL_MS})
_send({"type": "set_stream", "enable": true, "interval_ms": STREAM_INTERVAL_MS})
func _on_tap(data: Dictionary) -> void:
func _on_input(data: Dictionary) -> void:
if _phase != Phase.PLAYING or not data.get("success", false):
return
for event in data.get("events", []):
if typeof(event) != TYPE_DICTIONARY:
for client in data.get("clients", []):
if typeof(client) != TYPE_DICTIONARY:
continue
var cid := int(event.get("client_id", 0))
if str(client.get("tap_kind", "none")) == "none":
continue
var cid := int(client.get("client_id", 0))
if not _pod_digits.has(cid):
continue
if cid == _target_cid: