From 41ec69ab94fc44572fcbc6bc6b1ecc1fb2cd8287 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sat, 21 Jun 2025 20:37:45 -0600 Subject: [PATCH] WHYYYYYY --- debug.js | 33 +++++++++++++++++++++++++++++++++ index.js | 12 ++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 debug.js diff --git a/debug.js b/debug.js new file mode 100644 index 0000000..3fd3222 --- /dev/null +++ b/debug.js @@ -0,0 +1,33 @@ +const WebSocket = require('ws'); + +const wsUrl = 'wss://iem-alerter.ko4wal.radio/iem'; // Replace with actual WebSocket URL + +const ws = new WebSocket(wsUrl, {headers: { + 'User-Agent': 'iem-debugger/1.0', +}}); + +ws.on('open', () => { + console.log('WebSocket connection opened.'); + ws.send(JSON.stringify({"type":"subscribe"})); +}); + +ws.on('message', (data) => { + console.log("msg rx") + try { + const msg = JSON.parse(data); + // Assuming the message has 'channel' and 'product_id' fields + if (msg.channel && msg.product_data) { + console.log(`Channel: ${msg.channel}, Product ID: ${msg.product_data}`); + } + } catch (err) { + console.error('Error parsing message:', err); + } +}); + +ws.on('error', (err) => { + console.error('WebSocket error:', err); +}); + +ws.on('close', () => { + console.log('WebSocket connection closed.'); +}); \ No newline at end of file diff --git a/index.js b/index.js index cc737ab..449c140 100644 --- a/index.js +++ b/index.js @@ -516,8 +516,8 @@ xmpp.on("stanza", (stanza) => { connection.ws.send(JSON.stringify({ "type": "iem-message", "data": { - "channel": fromChannel, - "wfo": getWFOByRoom(fromChannel), + "channel": getWFOByRoom(fromChannel), + "fromChannel": fromChannel, "event": evt, "body": bodyData, "timestamp": product_id.timestamp, @@ -545,8 +545,8 @@ xmpp.on("stanza", (stanza) => { connection.ws.send(JSON.stringify({ "type": "iem-message", "data": { - "channel": fromChannel, - "wfo": getWFOByRoom(fromChannel), + "channel": getWFOByRoom(fromChannel), + "fromChannel": fromChannel, "event": evt, "body": bodyData.string, "timestamp": product_id.timestamp, @@ -573,8 +573,8 @@ xmpp.on("stanza", (stanza) => { evt, stanza, product_id, product_id_raw, bodyData, body, sentData: { "type": "iem-message", "data": { - "channel": fromChannel, - "wfo": getWFOByRoom(fromChannel), + "channel": getWFOByRoom(fromChannel), + "fromChannel": fromChannel, "event": evt, "body": bodyData, "timestamp": product_id.timestamp,