Skip to content

A TypeScript web socket implementation for ham radio clusters.

Notifications You must be signed in to change notification settings

k4ben/cluster-sockets

Repository files navigation

cluster-sockets

A TypeScript web socket implementation for ham radio clusters.

Installation

npm install cluster-sockets --save

Usage

Server (Built-in web server)

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);

Server (Existing HTTP or HTTPS server)

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);

Client

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);
});

TODO

  • Add error handling
  • Continue testing (module is extremely experimental at this stage)

About

A TypeScript web socket implementation for ham radio clusters.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published