-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
33 lines (26 loc) · 802 Bytes
/
index.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
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
io.on('connection', function(socket){
socket.on('connection', function(username, room){
console.log(username + " is connected.");
});
socket.on('disconnect', function(){
console.log("");
});
socket.on('exit', function(username, room){
console.log(username + " is disconnected.");
});
socket.on('chat message', function(username, msg, room){
console.log(username + ' > ' + msg);
});
socket.on('chat message', function(username, msg, room){
io.emit('chat message', username, msg, room);
});
});
http.listen(3000, function(){
console.log('listening on *:3000');
});