File tree Expand file tree Collapse file tree 6 files changed +34
-22
lines changed
src/ElectronNET.Samples.ElectronHostHook Expand file tree Collapse file tree 6 files changed +34
-22
lines changed Original file line number Diff line number Diff line change 1+ node_modules
2+ * .js
3+ * .js.map
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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}
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 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 >
You can’t perform that action at this time.
0 commit comments