-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
51 lines (43 loc) · 1.31 KB
/
server.js
File metadata and controls
51 lines (43 loc) · 1.31 KB
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
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
path = require('path');
app.configure(function () {
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
app.get('/', function (req, res) {
res.render('index.jade', {layout: false});
});
io.configure(function () {
io.enable('browser client minification');
io.enable('browser client etag');
io.enable('browser client gzip');
io.set('log level', 1);
io.set('polling duration', 3);
io.set('transport', [
'websocket',
'xhr-polling',
'flashsocket',
'htmlfile',
'json-polling']);
});
io.on('connection', function (client) {
client.on('paint', function (position) {
io.sockets.emit('paint', position);
});
client.on('clearPaint', function () {
io.sockets.emit('clearPaint');
});
});
server.listen(app.get('port'), function () {
console.log('Server startup on port ->', app.get('port'));
});