-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
32 lines (29 loc) · 941 Bytes
/
app.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
var app = require('express')();
var path = require('path');
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
var port = 8090;
server.listen(port);
console.log('se conecte na: http://localhost:' + port);
//Public web
app.get('/', function (req, res) {
res.sendfile(path.join(__dirname, '/index.html'));
});
app.get('/css/*', function(req, res){
res.sendfile(path.join(__dirname, '/css/', req.params[0]));
});
app.get('/js/*', function(req, res){
res.sendfile(path.join(__dirname, '/js/', req.params[0]));
});
app.get('/images/*', function(req, res){
res.sendfile(path.join(__dirname, '/images/', req.params[0]));
});
app.get('/sounds/*', function(req, res){
res.sendfile(path.join(__dirname, '/sounds/', req.params[0]));
});
//Sockets
io.sockets.on('connection', function (socket) {
socket.on('message', function (msg) {
socket.broadcast.emit('message', msg);
});
});