-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.js
More file actions
47 lines (32 loc) · 971 Bytes
/
chat.js
File metadata and controls
47 lines (32 loc) · 971 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var app = require('express')();
var http = require('http').Server(app);
//var io = require('socket.io')(http, {'transports': ['websocket']});
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendFile(__dirname + '/chat.html');
});
io.on('connection', function(socket){
socket.emit('local', '----');
socket.on('chat message', function(msg){
io.emit('chat message', msg);
});
socket.on('my other event', function(msg){
io.emit('local2', msg);
});
setTimeout(function() {
socket.emit('timer', '++++on');
// io.close();
// http.listen(3000, function(){
// console.log('listening on *:3000--');
// });
}, 10000);
// socket.on('disconnect', function () {
// socket.emit('client - close');
// http.listen(3000, function(){
// console.log('listening on *:3000--');
// });
// });
});
http.listen(3000, function(){
console.log('listening on *:3000');
});