MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / event

Function event

main.js:318–354  ·  view source on GitHub ↗
(clientId, category, action, options = {})

Source from the content-addressed store, hash-verified

316
317const DEBUG = false; // Set to true for development/debugging
318const PING_INTERVAL = 30000; // 30 seconds
319
320function debugLog(...args) {
321 if (DEBUG) {
322 console.log(...args);
323 }
324}
325
326// Server mode detection
327const isServerMode = process.argv.includes('--server');
328let httpServer = null;
329let httpServerEpoch = 0;
330let http80Server = null;
331let electronUiServer = null;
332let electronUiPort = null;
333let wss = null; // WebSocket server
334let wsClients = null; // WebSocket clients Set
335let letsEncryptRenewInFlight = false;
336
337// Store pending context menu actions for server mode (browser access)
338const pendingContextMenus = new Map();
339let contextMenuRequestIdCounter = 0;
340
341// Handler registry for WebSocket IPC calls in server mode
342// This allows us to directly invoke handlers without going through the renderer
343const ipcHandlerRegistry = new Map();
344
345// Auto-register every ipcMain.handle into the WebSocket registry.
346// Without this, Docker/server-mode falls back to executeJavaScript on the hidden
347// window for unregistered channels (e.g. getThumbnail) — which hangs/times out.
348const _ipcMainHandle = ipcMain.handle.bind(ipcMain);
349ipcMain.handle = (channel, handler) => {
350 ipcHandlerRegistry.set(channel, handler);
351 return _ipcMainHandle(channel, handler);
352};
353
354// Helper function to register IPC handlers and add them to the registry
355function registerIpcHandler(channel, handler) {
356 ipcMain.handle(channel, handler);
357}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected