Compare commits

...
9 Commits
Author SHA1 Message Date
kuba c2cbbdd3b9 fuck me 2026-04-04 22:47:59 +02:00
kuba f99ce973c1 no line end 2026-04-04 22:47:15 +02:00
kuba 6b5b48384f little change, dont even pull this 2026-04-04 22:34:05 +02:00
kuba e8d91086c7 whoops 2026-04-04 22:29:43 +02:00
kuba c0ad53563e count xrd users and also count the fm-dx users as secondary 2026-04-04 22:19:00 +02:00
kuba e0753c2479 oh! 2026-04-04 22:10:40 +02:00
kuba 7042074b31 still undefined 2026-04-04 22:07:18 +02:00
kuba 7ae8c4a24a huh? 2026-04-04 22:06:42 +02:00
kuba 431fc937ce send initial data, and also rename to xrd 2026-04-04 22:01:55 +02:00
4 changed files with 49 additions and 30 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
/* Libraries / Imports */ /* Libraries / Imports */
const send_to_rawcomm = require('./rawcomm'); const { send_xrd_online } = require('./xrd_server');
const RDSDecoder = require("./rds.js"); const RDSDecoder = require("./rds.js");
const { serverConfig } = require('./server_config'); const { serverConfig } = require('./server_config');
@@ -33,7 +33,7 @@ var dataToSend = {
ant: 0, ant: 0,
txInfo: { txInfo: {
tx: '', // Name tx: '', // Name
pol: '', // Polarisation pol: '', // Polarization
erp: '', // Power erp: '', // Power
city: '', city: '',
itu: '', // Country itu: '', // Country
@@ -274,7 +274,7 @@ checkSerialPortStatus();
function showOnlineUsers(currentUsers) { function showOnlineUsers(currentUsers) {
dataToSend.users = currentUsers; dataToSend.users = currentUsers;
initialData.users = currentUsers; initialData.users = currentUsers;
send_to_rawcomm(`o${currentUsers},0\n`); send_xrd_online(currentUsers);
} }
let prevFreq = initialData.freq || '87.500'; let prevFreq = initialData.freq || '87.500';
+2 -2
View File
@@ -7,7 +7,7 @@ const dataHandler = require('./datahandler');
const storage = require('./storage'); const storage = require('./storage');
const consoleCmd = require('./console'); const consoleCmd = require('./console');
const { serverConfig, configSave } = require('./server_config'); const { serverConfig, configSave } = require('./server_config');
const send_to_rawcomm = require("./rawcomm") const { send_to_xrd } = require("./xrd_server")
let geoip = null; let geoip = null;
try { try {
@@ -276,7 +276,7 @@ function resolveDataBuffer(data, wss, rdsWss) {
if (receivedData.length) { if (receivedData.length) {
dataHandler.handleData(wss, receivedData, rdsWss); dataHandler.handleData(wss, receivedData, rdsWss);
send_to_rawcomm(receivedData); send_to_xrd(receivedData);
} }
} }
-25
View File
@@ -1,25 +0,0 @@
const storage = require('./storage');
const WebSocket = require('ws');
const rawComm = new WebSocket.Server({ noServer: true });
rawComm.on('connection', (ws, request) => {
const { isAdminAuthenticated } = request.session || {};
if(!isAdminAuthenticated) {
ws.close(1008, "No admin");
return;
}
ws.on('message', (message) => {
storage.ctl_output.write(`${message.toString()}\n`);
});
});
storage.websocket_delegation.set("/rawcomm", rawComm);
function send_to_rawcomm(data) {
rawComm.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) client.send(data);
});
}
module.exports = send_to_rawcomm;
+44
View File
@@ -0,0 +1,44 @@
const storage = require('./storage');
const WebSocket = require('ws');
const xrd = new WebSocket.Server({ noServer: true });
let currentUsers = 0;
function send_to_xrd(data) {
xrd.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) client.send(data);
});
}
function send_xrd_online(fmusers) {
send_to_xrd(`o${currentUsers},${fmusers}\n`);
}
xrd.on('connection', (ws, request) => {
const { initialData } = require('./datahandler');
const { isAdminAuthenticated } = request.session || {};
if(!isAdminAuthenticated) {
ws.close(1008, "No admin");
return;
}
currentUsers++;
send_xrd_online(initialData.users);
ws.send(`T${initialData.freq * 1000}\n`);
ws.send(`G${initialData.eq}${initialData.ims}\n`);
ws.send(`Z${initialData.ant}\n`);
ws.send(`A${initialData.agc}\n`);
ws.send(`F${initialData.bw}\n`);
ws.send(`W${initialData.bw}\n`);
ws.send(`OK\n`);
ws.on('message', (message) => storage.ctl_output.write(message));
ws.on('close', (code, reason) => {
currentUsers--;
send_xrd_online(initialData.users);
});
});
storage.websocket_delegation.set("/xrd", xrd);
module.exports = { send_to_xrd, send_xrd_online };