Skip to content

Commit 331c2f5

Browse files
fix: address review comments (protocol, config, startup)
1 parent b00adcb commit 331c2f5

File tree

6 files changed

+34
-22
lines changed

6 files changed

+34
-22
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
*.js
3+
*.js.map

src/ElectronNET.Samples.ElectronHostHook/ElectronHostHook/connector.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ export class Connector {
77
on(key: string, javaScriptCode: Function): void {
88
this.socket.on(key, (...args: any[]) => {
99
const id: string = args.pop();
10-
const done = (result: any) => {
11-
this.socket.emit(id, result);
12-
};
13-
14-
args = [...args, done];
15-
javaScriptCode(...args);
10+
try {
11+
javaScriptCode(...args, (data) => {
12+
if (data) {
13+
this.socket.emit(`${key}Complete${id}`, data);
14+
}
15+
});
16+
} catch (error) {
17+
this.socket.emit(`${key}Error${id}`, `Host Hook Exception`, error);
18+
}
1619
});
1720
}
1821
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "electron-host-hook",
3+
"version": "1.0.0",
4+
"description": "Connector for Electron.NET projects.",
5+
"main": "index.js",
6+
"dependencies": {
7+
"socket.io": "^4.8.1"
8+
},
9+
"devDependencies": {
10+
"typescript": "^5.9.3"
11+
}
12+
}
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
{
22
"compilerOptions": {
33
"module": "commonjs",
4-
"noImplicitAny": false,
5-
"noEmitOnError": true,
6-
"removeComments": false,
4+
"target": "ES2019",
75
"sourceMap": true,
8-
"target": "es5",
9-
"lib": ["es2015", "dom"]
6+
"skipLibCheck": true
107
},
11-
"exclude": ["node_modules", "wwwroot"]
8+
"exclude": ["node_modules"]
129
}

src/ElectronNET.Samples.ElectronHostHook/Program.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ public static void Main(string[] args)
88
{
99
var builder = WebApplication.CreateBuilder(args);
1010

11-
builder.WebHost.UseElectron(args);
11+
builder.WebHost.UseElectron(args, async () =>
12+
{
13+
var window = await Electron.WindowManager.CreateWindowAsync();
14+
});
15+
1216
builder.Services.AddElectron();
1317
builder.Services.AddControllersWithViews();
1418

@@ -21,14 +25,6 @@ public static void Main(string[] args)
2125
name: "default",
2226
pattern: "{controller=Home}/{action=Index}/{id?}");
2327

24-
if (HybridSupport.IsElectronActive)
25-
{
26-
Task.Run(async () =>
27-
{
28-
var window = await Electron.WindowManager.CreateWindowAsync();
29-
});
30-
}
31-
3228
app.Run();
3329
}
3430
}

src/ElectronNET.Samples.ElectronHostHook/Views/Home/Index.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
}
55

66
<!DOCTYPE html>
7-
<html>
7+
<html lang="en">
88
<head>
9+
<meta charset="utf-8">
910
<meta name="viewport" content="width=device-width" />
1011
<title>ElectronHostHook Sample</title>
1112
<style>

0 commit comments

Comments
 (0)