Skip to content

Commit 42e816e

Browse files
committed
Updated sample connector
1 parent 03c0850 commit 42e816e

File tree

11 files changed

+773
-1356
lines changed

11 files changed

+773
-1356
lines changed

src/ElectronNET.WebApp/ElectronHostHook/connector.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/ElectronNET.WebApp/ElectronHostHook/connector.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/ElectronNET.WebApp/ElectronHostHook/connector.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/ElectronNET.WebApp/ElectronHostHook/excelCreator.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/ElectronNET.WebApp/ElectronHostHook/excelCreator.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/ElectronNET.WebApp/ElectronHostHook/index.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/ElectronNET.WebApp/ElectronHostHook/index.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
1-
// @ts-ignore
2-
import * as Electron from "electron";
3-
import { Connector } from "./connector";
1+
import { App } from "electron";
2+
import { Socket } from "socket.io";
43
import { ExcelCreator } from "./excelCreator";
54

6-
export class HookService extends Connector {
7-
constructor(socket: SocketIO.Socket, public app: Electron.App) {
8-
super(socket, app);
9-
}
5+
export class HookService {
6+
constructor(private socket: Socket, public app: App) {}
107

11-
onHostReady(): void {
12-
// execute your own JavaScript Host logic here
13-
this.on("create-excel-file", async (path, done) => {
14-
const excelCreator: ExcelCreator = new ExcelCreator();
15-
const result: string = await excelCreator.create(path);
8+
private on(key: string, cb: (...args: Array<any>) => void): void {
9+
this.socket.on(key, (...args: Array<any>) => {
10+
const id: string = args.pop();
1611

17-
done(result);
12+
try {
13+
cb(...args, (data) => {
14+
if (data) {
15+
this.socket.emit(`${key}Complete${id}`, data);
16+
}
1817
});
19-
}
20-
}
18+
} catch (error) {
19+
this.socket.emit(`${key}Error${id}`, `Host Hook Exception`, error);
20+
}
21+
});
22+
}
2123

24+
onHostReady(): void {
25+
// execute your own JavaScript Host logic here
26+
this.on("create-excel-file", async (path, done) => {
27+
const excelCreator: ExcelCreator = new ExcelCreator();
28+
const result: string = await excelCreator.create(path);
29+
30+
done(result);
31+
});
32+
}
33+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy