mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-07-29 16:29:19 +02:00
send initial data, and also rename to xrd
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* Libraries / Imports */
|
||||
const send_to_rawcomm = require('./rawcomm');
|
||||
const send_to_xrd = require('./xrd_server');
|
||||
const RDSDecoder = require("./rds.js");
|
||||
const { serverConfig } = require('./server_config');
|
||||
|
||||
@@ -33,7 +33,7 @@ var dataToSend = {
|
||||
ant: 0,
|
||||
txInfo: {
|
||||
tx: '', // Name
|
||||
pol: '', // Polarisation
|
||||
pol: '', // Polarization
|
||||
erp: '', // Power
|
||||
city: '',
|
||||
itu: '', // Country
|
||||
@@ -274,7 +274,7 @@ checkSerialPortStatus();
|
||||
function showOnlineUsers(currentUsers) {
|
||||
dataToSend.users = currentUsers;
|
||||
initialData.users = currentUsers;
|
||||
send_to_rawcomm(`o${currentUsers},0\n`);
|
||||
send_to_xrd(`o${currentUsers},0\n`);
|
||||
}
|
||||
|
||||
let prevFreq = initialData.freq || '87.500';
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ const dataHandler = require('./datahandler');
|
||||
const storage = require('./storage');
|
||||
const consoleCmd = require('./console');
|
||||
const { serverConfig, configSave } = require('./server_config');
|
||||
const send_to_rawcomm = require("./rawcomm")
|
||||
const send_to_xrd = require("./xrd_server")
|
||||
|
||||
let geoip = null;
|
||||
try {
|
||||
@@ -276,7 +276,7 @@ function resolveDataBuffer(data, wss, rdsWss) {
|
||||
|
||||
if (receivedData.length) {
|
||||
dataHandler.handleData(wss, receivedData, rdsWss);
|
||||
send_to_rawcomm(receivedData);
|
||||
send_to_xrd(receivedData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -0,0 +1,33 @@
|
||||
const storage = require('./storage');
|
||||
const datahandler = require('./datahandler');
|
||||
const WebSocket = require('ws');
|
||||
const xrd = new WebSocket.Server({ noServer: true });
|
||||
|
||||
xrd.on('connection', (ws, request) => {
|
||||
const { isAdminAuthenticated } = request.session || {};
|
||||
if(!isAdminAuthenticated) {
|
||||
ws.close(1008, "No admin");
|
||||
return;
|
||||
}
|
||||
|
||||
ws.send(`o${datahandler.initialData.users},0\n`);
|
||||
ws.send(`T${datahandler.initialData.freq * 1000}\n`);
|
||||
ws.send(`G${datahandler.initialData.eq}${datahandler.initialData.ims}\n`);
|
||||
ws.send(`Z${datahandler.initialData.ant}\n`);
|
||||
ws.send(`A${datahandler.initialData.agc}\n`);
|
||||
ws.send(`F${datahandler.initialData.bw}\n`);
|
||||
ws.send(`W${datahandler.initialData.bw}\n`);
|
||||
ws.send(`OK\n`);
|
||||
|
||||
ws.on('message', (message) => storage.ctl_output.write(`${message}\n`));
|
||||
});
|
||||
|
||||
storage.websocket_delegation.set("/xrd", xrd);
|
||||
|
||||
function send_to_xrd(data) {
|
||||
xrd.clients.forEach((client) => {
|
||||
if (client.readyState === WebSocket.OPEN) client.send(data);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = send_to_xrd;
|
||||
Reference in New Issue
Block a user