-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (31 loc) · 1.03 KB
/
server.js
File metadata and controls
38 lines (31 loc) · 1.03 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
var express = require('express');
var app = express.createServer();
var io = require('socket.io').listen(app);
io.enable('browser client minification'); // send minified client
io.enable('browser client etag'); // apply etag caching logic based on version number
io.set('log level', 1); // reduce logging
io.set('transports', [ // enable all transports (optional if you want flashsocket)
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]);
app.configure(function () {
app.use(express.static(__dirname + '/public'));
});
app.set("view options", { layout: false })
app.listen(8080);
app.get('/', function (req, res) {
res.render('index.html');
});
//var allnotedata = [];
io.sockets.on('connection', function (socket) {
// send all note data we have
//socket.emit('allnotedata', allnotedata);
// send updates to other clients
socket.on('notedata', function (data) {
console.log(data);
socket.broadcast.emit('notedata', data);
});
});