From 8f2637c39ff9466a920b048f16d15920aa9c8ee4 Mon Sep 17 00:00:00 2001 From: DJ2LS Date: Mon, 13 Nov 2023 07:20:06 +0100 Subject: [PATCH] first test with event sock connection state --- gui/src/js/eventHandler.js | 7 +++++++ gui/src/js/event_sock.js | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gui/src/js/eventHandler.js b/gui/src/js/eventHandler.js index 9cacfd0b..58a997e9 100644 --- a/gui/src/js/eventHandler.js +++ b/gui/src/js/eventHandler.js @@ -19,9 +19,16 @@ const stateStore = useStateStore(pinia); import { useSettingsStore } from "../store/settingsStore.js"; const settings = useSettingsStore(pinia); +export function connectionFailed(endpoint, event){ + stateStore.modem_connection = "disconnected" + +} export function stateDispatcher(data) { console.log(data); + stateStore.modem_connection = "connected" + + if (data["freedata-message"] == "state-change") { stateStore.channel_busy = data["channel_busy"]; stateStore.is_codec2_traffic = data["is_codec2_traffic"]; diff --git a/gui/src/js/event_sock.js b/gui/src/js/event_sock.js index 798a3a52..22d6e17b 100644 --- a/gui/src/js/event_sock.js +++ b/gui/src/js/event_sock.js @@ -1,4 +1,4 @@ -import { eventDispatcher, stateDispatcher } from "../js/eventHandler.js"; +import { eventDispatcher, stateDispatcher, connectionFailed } from "../js/eventHandler.js"; import { addDataToWaterfall } from "../js/waterfallHandler.js"; function connect(endpoint, dispatcher) { @@ -17,6 +17,7 @@ function connect(endpoint, dispatcher) { // handle errors socket.addEventListener("error", function (event) { console.error("WebSocket error:", event); + connectionFailed(endpoint, event) }); // handle closing and reconnect