forked from Hammster/electron-edge-js-quick-start
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrenderer.js
143 lines (106 loc) · 3.83 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
const path = require('path');
var version = location.search.split('version=')[1];
var namespace = 'QuickStart.' + version.charAt(0).toUpperCase() + version.substr(1);
if(version === 'core') version = 'coreapp';
const baseNetAppPath = path.join(__dirname, '/src/'+ namespace +'/bin/Debug/net5.0');
process.env.EDGE_USE_CORECLR = 1;
process.env.EDGE_DEBUG = 1;
console.log(JSON.stringify(process.versions, null, 2));
if(version !== 'standard')
process.env.EDGE_APP_ROOT = baseNetAppPath;
var edge = require('electron-edge-js');
var baseDll = path.join(baseNetAppPath, namespace + '.dll');
var localTypeName = namespace + '.LocalMethods';
var externalTypeName = namespace + '.ExternalMethods';
var getAppDomainDirectory = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'GetAppDomainDirectory'
});
var getCurrentTime = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'GetCurrentTime'
});
var useDynamicInput = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'UseDynamicInput'
});
var getPerson = edge.func({
assemblyFile: baseDll,
typeName: externalTypeName,
methodName: 'GetPersonInfo'
});
var getDelegate = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'GetDelegateHandle'
});
var getComplexObject = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'GetComplexObject'
});
var getFromThread = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'GetFromThread'
});
var registerEventCallback = edge.func({
assemblyFile: baseDll,
typeName: localTypeName,
methodName: 'RegisterEventCallback'
});
window.onload = function() {
document.getElementById("ProcessVersions").innerHTML = `<pre>${JSON.stringify(process.versions, null, 2)}</pre>`
getAppDomainDirectory('', function(error, result) {
if (error) throw error;
document.getElementById("GetAppDomainDirectory").innerHTML = result;
});
getCurrentTime('', function(error, result) {
if (error) throw error;
document.getElementById("GetCurrentTime").innerHTML = result;
});
useDynamicInput('Node.Js', function(error, result) {
if (error) throw error;
document.getElementById("UseDynamicInput").innerHTML = result;
});
getPerson('', function(error, result) {
//if (error) throw JSON.stringify(error);
document.getElementById("GetPersonInfo").innerHTML = result;
});
getDelegate('', function(error, result){
if(error) throw error;
console.log(result);
var getTimeFunc = result.GetCurrentTime;
getTimeFunc('', function(error, result){
if(error) throw error;
console.log(result);
document.getElementById("GetCurrentTimeFromDelegate").innerHTML = result;
});
})
getComplexObject('', function(error, result){
if(error) throw error;
console.log(result);
document.getElementById("GetDictionary").innerHTML = result['test'] + "\r\n" + result['now'] + "\r\n" + result['long'];
})
getFromThread('', function(error, result){
if(error) throw error;
console.log(result);
})
registerEventCallback({EventCallback: OnTimerElapsed}, function(error, result){
if(error) throw error;
console.log('Registering done')
})
};
function OnTimerElapsed(signalTime, callback ){
document.getElementById("OnTimerElapsed").innerHTML = signalTime
console.log(signalTime)
// result of method
var result = 123;
// "complete method" with (error, result) return values reported via the given callback
callback(null, result);
// error case
// callback(new Error("Exception in OnTimeElapsed"), result);
}