-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
56 lines (44 loc) · 1.53 KB
/
server.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
//Firstly import settings
const settings = require('./config/settings.json');
//Import logging stuff
const logger = require("winston");
const logging = require("./src/utils/logging");
const chalk = require("chalk");
//Import web socket server
const { WebSocketServer } = require('ws');
//Import utils
const { initPing, defaultPingHandler } = require("./src/utils/ping");
const { initKeypresses, defaultKeypressHandler } = require('./src/utils/keypresses');
const { sendWelcomeMessage } = require('./src/utils/logging');
//Import behaviour
const carousel = require("./src/behaviours/carousel");
function checkForWarnings()
{
//Send warnings if needed
if (settings.authorisationToken == "password")
{
// console.clear();
console.log(chalk.red.bold("WARNING"))
console.log(chalk.red.bold("The specified authorisation token has not been changed. It is advised that you change this immediately for security purposes."));
console.log("");
}
}
function start()
{
//Initialise logging and send welcome message
logging.initialise();
logging.sendWelcomeMessage();
//Check for config warnings
checkForWarnings();
//Make a new server
let wss = new WebSocketServer({ port: settings.hostPort });
logging.sendServerStartMessage(wss);
logging.setUpMessages(wss);
//Initialise ping & default keypresses
initPing(wss, defaultPingHandler);
initKeypresses(wss, defaultKeypressHandler);
//Call init for carousel
carousel.initialise(wss);
}
//Start everything up
start();