-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
defaultService.example.js
81 lines (66 loc) · 2.25 KB
/
defaultService.example.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
// defaultService.example.js
// https://github.com/gnh1201/welsonjs
var SYS = require("lib/system");
// Examples of class (prototype) and instance referencing .env values
function examplePrototype() {
this.env = {};
this.setEnv = function(k, v) {
this.env[k] = v;
};
}
var exampleInstance = new examplePrototype();
function main(args) {
console.log("WelsonJS.Service required.");
}
function getDeviceID() {
return SYS.getUUID();
}
function onServiceStart(args) {
// load the environment file
FILE.loadEnvFromArgs(args, function(envConfig) {
// In Node.js and recent JavaScript engines, it is common to assign .env values globally, such as with `process.env`.
// However, WelsonJS is designed to limit the scope to specific areas.
for (var envKey in envConfig) {
exampleInstance.setEnv(envKey, envConfig[envKey]);
}
});
return "onServiceStart recevied. " + args.join(', ') + ", env: " + JSON.stringify(exampleInstance.env);
}
function onServiceStop() {
return "onServiceStop recevied";
}
function onServiceElapsedTime() {
return "onServiceElapsedTime recevied";
}
function onMessageReceived() {
return "onMessageReceived recevied. " + args.join(', ');
}
function onScreenNextTemplate(args) {
return "example.png";
}
function onScreenTemplateMatched(args) {
return "onScreenTemplateMatched recevied. " + args.join(', ');
}
function onFileCreated(args) {
return "onFileCreated recevied. " + args.join(', ');
}
function onNetworkConnected(args) {
return "onNetworkConnected recevied. " + args.join(', ');
}
function onRegistryModified(args) {
return "onRegistryModified recevied. " + args.join(', ');
}
function onAvScanResult(args) {
return "onAvScanResult recevied. " + args.join(', ');
}
exports.main = main;
exports.getDeviceID = getDeviceID;
exports.onServiceStart = onServiceStart;
exports.onServiceStop = onServiceStop;
exports.onServiceElapsedTime = onServiceElapsedTime;
exports.onScreenNextTemplate = onScreenNextTemplate;
exports.onScreenTemplateMatched = onScreenTemplateMatched;
exports.onFileCreated = onFileCreated;
exports.onNetworkConnected = onNetworkConnected;
exports.onRegistryModified = onRegistryModified;
exports.onAvScanResult = onAvScanResult;