-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.js
More file actions
27 lines (20 loc) · 674 Bytes
/
Copy pathhello.js
File metadata and controls
27 lines (20 loc) · 674 Bytes
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
var express = require('express');
var app = express.createServer(express.logger()), io = require('socket.io').listen(app);
io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});
app.get('/', function(request, response) {
response.sendfile(__dirname + '/index.html');
});
var port = process.env.PORT || 80;
console.log("Listening on " + port);
app.listen(port);
io.sockets.on('connection', function (socket) {
socket.broadcast.emit('news from the server');
socket.on('message', function (data) {
console.log('message on server');
//socket.broadcast.emit(data);
socket.broadcast.send(data);
});
});