Skip to content

Commit 3d74a3c

Browse files
refactor: use ES6 syntax for the server code
We'll keep ES5 syntax for the client code so it still runs in IE11.
1 parent 68fd421 commit 3d74a3c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
var app = require('express')();
2-
var http = require('http').Server(app);
3-
var io = require('socket.io')(http);
4-
var port = process.env.PORT || 3000;
1+
const app = require('express')();
2+
const http = require('http').Server(app);
3+
const io = require('socket.io')(http);
4+
const port = process.env.PORT || 3000;
55

6-
app.get('/', function(req, res){
6+
app.get('/', (req, res) => {
77
res.sendFile(__dirname + '/index.html');
88
});
99

10-
io.on('connection', function(socket){
11-
socket.on('chat message', function(msg){
10+
io.on('connection', (socket) => {
11+
socket.on('chat message', msg => {
1212
io.emit('chat message', msg);
1313
});
1414
});
1515

16-
http.listen(port, function(){
17-
console.log('listening on *:' + port);
16+
http.listen(port, () => {
17+
console.log(`Socket.IO server running at http://localhost:${port}/`);
1818
});

0 commit comments

Comments
 (0)