Page MenuHomeSealhub

notifier.ts
No OneTemporary

notifier.ts

import WebSocket from "ws";
export function make_notifier(port: number) {
const server = new WebSocket.Server({
port,
});
let sockets: WebSocket[] = [];
server.on("connection", function (socket) {
sockets.push(socket);
// When a socket closes, or disconnects, remove it from the array.
socket.on("close", function () {
sockets = sockets.filter((s) => s !== socket);
});
});
console.log("build notifier listening on websocket at port " + port);
return function notify(message: string) {
sockets.forEach((s) => s.send(message));
};
}

File Metadata

Mime Type
text/x-java
Expires
Fri, Nov 22, 17:57 (16 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
547725
Default Alt Text
notifier.ts (559 B)

Event Timeline