-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
42 lines (34 loc) · 1.01 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
// On require les modules dont on a besoin
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server);
// On initialise le serveur node.js
server.listen(3000);
// Routes
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
// Dossiers
app.use("/css", express.static(__dirname + '/css'));
app.use("/js", express.static(__dirname + '/js'));
app.use("/node_modules", express.static(__dirname + '/node_modules'));
io.sockets.on( 'connection', function( socket ){
console.log( "Someone connected to the application." )
socket.on('showCmds', function(){
var list = {};
for(cmd in cmdList){
if(cmdList[cmd].auth <= user._authority){
list[cmd] = cmdList[cmd].desc;
}
}
socket.emit( 'showCmds', list );
});
socket.on( "draw", function( data ){
console.log( data );
socket.broadcast.emit( "userDrew", data );
} );
socket.on( 'disconnect', function(){
console.log( "Someone disconnected." );
} );
} );