-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
58 lines (38 loc) · 2.08 KB
/
main.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
"use strict";
//External libraries
const childProc = require("child_process"),
storage = require("node-persist"),
event = require("./modules/event"),
//Service calls
fetchNewsData = require("./modules/services/fetchNewsData"),
fetchWeatherData = require("./modules/services/fetchWeatherData"),
wikiQuery = require("./modules/services/wikiQuery"),
spanishQuizz = require("./modules/services/spanishQuizz"),
spanish = require("./modules/services/spanish"),
//Internal libraries
app = require("./modules/speechServer"),
boardSetUp = require("./modules/hardware/boardSetUp"),
morning = require("./modules/morning"),
welcomeHome = require("./modules/welcomeHome"),
timer = require("./modules/timer"),
piServer = require("./modules/piServer"),
io = require("socket.io").listen(server),
//Over-ride kernal level functions
musicControls = require("./modules/kernal-overide/musicControls"),
browserControls = require("./modules/kernal-overide/browserControls");
//Establish link with the front end and handle socket events
io.on("connection", socket => {
storage.init()
// console.log(global.event)
//Binds events to sockets: Sockets must be named after their event in order to stay tidy
global.event.eventNames().forEach(name => {socket.on(name, res => {global.event.emit(name,res)})})
//Binds sockets to events: Events must be named after their socket in order to stay tidy
const socket_list = ["speechFromBackEnd","wikiResult","news","speechFromBackEndSpanish","weather","spotifyTrackInfo","trackTimeInfo"]
socket_list.forEach(name => {global.event.on(name, res => {socket.emit(name,res)})})
});
global.event.emit("checkStatus", () => {
let session_data = io.nsps["/"].connected;
if (Object.keys(session_data).length === 0) {
global.event.emit("openApplication", "Jarvis")
}
});