From 132b20b4ae797043d5895f52533ff2f109fd291f Mon Sep 17 00:00:00 2001 From: Robert Muehsig Date: Mon, 7 Jan 2019 22:27:33 +0100 Subject: [PATCH] adding the connector --- ElectronNET.CLI/ElectronNET.CLI.csproj | 1 + ElectronNET.Host/ElectronHostHook/connector.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 ElectronNET.Host/ElectronHostHook/connector.ts diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj index 81e0b74..ef3e6df 100644 --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -58,6 +58,7 @@ This package contains the dotnet tooling to electronize your application. + diff --git a/ElectronNET.Host/ElectronHostHook/connector.ts b/ElectronNET.Host/ElectronHostHook/connector.ts new file mode 100644 index 0000000..94e5b4b --- /dev/null +++ b/ElectronNET.Host/ElectronHostHook/connector.ts @@ -0,0 +1,13 @@ +export class Connector { + constructor(private socket: SocketIO.Socket, public app: Electron.App) { } + + on(key: string, javaScriptCode: Function): void { + this.socket.on(key, (...args: any[]) => { + const id: string = args.pop(); + + javaScriptCode(args, (data) => { + this.socket.emit(`${key}Complete${id}`, data); + }); + }); + } +}