Add IPC to templates and handle helper function server

This commit is contained in:
Cooldude2606 committed 2024-01-24 00:40:22 +00:00
1 parent 2916dcc58c
commit 58231cc02c
11 files changed
+78 -19

No files matched your search

+7
View File
@@ -562,6 +562,13 @@ export class FactorioServer extends events.EventEmitter {
}
}
// TODO at the moment this is just a helper function, it has the potential for schema checking
handle<Event>(eventName: string, handler: (event: Event) => Promise<void>) {
this.on(eventName, (event) => handler(event).catch(err => {
this._logger.error(`Error handling ipc event:\n${err.stack}`);
}));
}
async _handleIpc(line: Buffer) {
let channelEnd = line.indexOf("?");
if (channelEnd === -1) {