first test with event sock connection state

This commit is contained in:
DJ2LS 2023-11-13 07:20:06 +01:00
parent 26be304699
commit 8f2637c39f
2 changed files with 9 additions and 1 deletions

View file

@ -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"];

View file

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