File tree 1 file changed +9
-9
lines changed 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 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 ;
5
5
6
- app . get ( '/' , function ( req , res ) {
6
+ app . get ( '/' , ( req , res ) => {
7
7
res . sendFile ( __dirname + '/index.html' ) ;
8
8
} ) ;
9
9
10
- io . on ( 'connection' , function ( socket ) {
11
- socket . on ( 'chat message' , function ( msg ) {
10
+ io . on ( 'connection' , ( socket ) => {
11
+ socket . on ( 'chat message' , msg => {
12
12
io . emit ( 'chat message' , msg ) ;
13
13
} ) ;
14
14
} ) ;
15
15
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 } /` ) ;
18
18
} ) ;
You can’t perform that action at this time.
0 commit comments