-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
54 lines (42 loc) · 1.41 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
// Libraries / Frameworks
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var path = require('path');
var express = require('express');
// Custom Modules
var loginHandler = require('./server/network/loginHandler');
var userHandler = require('./server/network/userHandler');
var masterHandler = require('./server/network/masterHandler');
const userData = require('./server/users/userData');
// Assign io() var in Submodules
masterHandler.io = io;
// ExpressJS Configuration
app.use(express.static(path.join(__dirname, 'client')));
app.get('/', function(req, res){
res.sendFile(path.join(__dirname, 'client/layout/login.html'));
});
app.get('/quiz', function(req, res){
res.sendFile(path.join(__dirname, 'client/layout/quiz.html'));
});
app.get('/master', function(req, res){
res.sendFile(path.join(__dirname, 'client/layout/master.html'));
});
io.on('connection', function (socket) {
console.log('Connected client');
loginHandler.login(socket);
loginHandler.validation(socket);
loginHandler.userList(socket);
userHandler.pageUpdates(socket);
userHandler.input(socket);
masterHandler.pageUpdates(socket);
masterHandler.controls(socket);
masterHandler.scores(socket);
socket.on('disconnect', function(){
userData.removeSocket(socket.id);
console.log('Disconnected client');
});
});
http.listen(80, function(){
console.log('listening on *:80');
});