// TODO: In dev mode, this won't update unless explicitly calling webpack import { BackgroundRoomStore } from "./background/BackgroundRoomStore"; import { init } from "./background/serverIpc"; const handlers = {}; let isDev: any; let version: any; console.log("STORE CREATED"); if (process.argv[2] === "--subprocess") { isDev = false; version = process.argv[3]; let socketName = process.argv[4]; init(socketName, handlers); BackgroundRoomStore.createNew().then((currentStore) => { process.on("message", (message) => { if (message.type === "add-room") { currentStore.addRoomId(message.roomId); } else if (message.type === "close-room") { currentStore.closeRoom(message.roomId); } }); }); } else { /* * TODO: Nasty as fuck renderer bug here. * BackgroundRoomStore needs to wait for a successful socket connection, but ipcRenderer * immediately sends set socket signal, so event handler must be called first */ const { ipcRenderer, remote } = require("electron"); isDev = true; version = remote.app.getVersion(); ipcRenderer.on("set-socket", (event: any, { name }: { name: string }) => { init(name, handlers); }); console.log("ADDING ROOM ID SERVER SIDE"); BackgroundRoomStore.createNew().then((currentStore) => { ipcRenderer.on("add-room", (event: any, { roomId }: { roomId: string }) => { currentStore.addRoomId(roomId); }); ipcRenderer.on( "close-room", (event: any, { roomId }: { roomId: string }) => { currentStore.closeRoom(roomId); } ); }); } console.log("SERVER.TS"); console.log(version, isDev); // TODO: figure out where to put this export { };