-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
48 lines (36 loc) · 1.17 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// app.js
var express = require('express'),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
_ = require('underscore');
var port = process.env.PORT;
app.use(express.static(__dirname + '/site')); // + '/public'));
io.sockets.on('connection', function(socket) {
socket.on('createCard', function (data) {
socket.broadcast.emit('onCardCreated', data);
});
socket.on('deleteCards', function () {
socket.broadcast.emit('onCardsDeleted');
});
socket.on('onToggle', function (val) {
socket.broadcast.emit('onToggle', val);
});
socket.on('onTaskChanged', function (val) {
socket.broadcast.emit('onTaskChanged', val);
});
socket.on('onCardsChanged', function (data) {
socket.broadcast.emit('onCardsChanged', data);
});
socket.on('setLeader', function () {
socket.broadcast.emit('onLeaderSet');
});
socket.on('resetLeader', function () {
socket.broadcast.emit('onLeaderReset');
});
socket.on('addUser', function (data) {
socket.broadcast.emit('onUserAdded', data);
});
});
// A.3
server.listen(port);