import fastJson from "fast-json-stringify"; import ipc from "node-ipc"; const stringify = fastJson({ title: "Mouse Movements", type: "object", properties: { type: { type: "string", }, name: { type: "string", }, args: { type: "object", properties: { name: { type: "string", }, userId: { type: "string", }, x: { type: "number", }, y: { type: "number", }, timestamp: { type: "number", nullable: true, }, }, }, }, }); export function init(socketName: string, handlers: any) { ipc.config.id = socketName; ipc.config.silent = true; ipc.serve(() => { ipc.server.on("message", (data, socket) => { console.log("IPC SERVER RECEIVED MESSAGE"); console.log(data); console.log(socket); }); }); ipc.server.start(); } export function send(name: string, args: any) { (ipc.server as any).broadcast( "message", stringify({ type: "push", name, args }) ); console.log("NODE IPC SERVER SENDING"); console.log(args); }