A TypeScript web socket implementation for ham radio clusters.
npm install cluster-sockets --save
const { ClusterServer } = require('cluster-sockets');
const callsign = "N0CAL"; // Replace with your callsign
const clusterServer = new ClusterServer(callsign, {
hostname: "telnet.reversebeacon.net",
port: 7000,
type: "rbn"
}, 80);
const { createServer } = require ('http');
const { ClusterServer } = require('cluster-sockets');
const callsign = "N0CAL"; // Replace with your callsign
const webServer = createServer();
webServer.listen(80);
const clusterServer = new ClusterServer(callsign, {
hostname: "telnet.reversebeacon.net",
port: 7000,
type: "rbn"
}, webServer);
const { ClusterClient } = require('cluster-sockets');
const clusterClient = new ClusterClient("ws://localhost");
clusterClient.on("connected", async ()=> {
const clusters = await clusterClient.list(); // Array of ClusterOptions
clusterClient.join(0); // Joins the cluster at index 0 of "clusters";
// Later
clusterClient.leave(0);
});
clusterClient.on("spot", clusterSpot => {
if (clusterSpot.spot.dxCall != "N0CAL") return;
console.log(`You've been spotted by ${clusterSpot.hostname}:${clusterSpot.port}!`);
console.log(clusterSpot.spot);
});
- Add error handling
- Continue testing (module is extremely experimental at this stage)