-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (41 loc) · 1.22 KB
/
index.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
// ================================================================================
//
// PLEASE READ:
// This project is under a GPL-3 license, you are REQUIRED to publicly publish any
// changes or upgrades you make to the codebase, it strengthens the community.
// Contact the maintainer if you have any questions regarding the license.
//
// ================================================================================
const path = require("path")
const child_process = require("child_process")
const config = require("./loadconfig")
let hasMap = false
let connTimeout = false
var win = false
let gsi = child_process.fork(`${__dirname}/gsi.js`)
let http = child_process.fork(`${__dirname}/http.js`)
let socket = child_process.fork(`${__dirname}/socket.js`)
function setActivePage(page) {
http.send(page)
socket.send({
type: "pageUpdate"
})
}
gsi.on("message", (message) => {
socket.send(message)
if (!hasMap) {
if (message.type == "map") {
setActivePage("map")
hasMap = true
console.info(`Map ${message.data} selected`)
}
}
})
function cleanup() {
gsi.kill()
http.kill()
socket.kill()
}
for (let signal of ["exit", "SIGINT", "SIGUSR1", "SIGUSR2"]) {
process.on(signal, cleanup)
}