-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathio-server.js
More file actions
47 lines (38 loc) · 1.16 KB
/
io-server.js
File metadata and controls
47 lines (38 loc) · 1.16 KB
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 io = require('socket.io')();
// var fs = require("fs");
// var fs = require('fs');
// var tempBuffer = new Buffer(0);
// function readLines(input) {
// input.on('data', function (data) {
// // console.log(data);
// tempBuffer = Buffer.concat([tempBuffer, data]);
// });
// input.on('end', function () {
// // console.log("end" + tempBuffer);
// });
// }
// var input = fs.createReadStream('E:\\weex-test\\sockt\\public\\clothes.png');
// readLines(input);
var clients = []
io.on('connection', function (client) {
clients.push(client);
console.log('connection!');
client.emit('join', 'welcome to join!!')
// setInterval(function () {
// console.log("send setInterval");
// // client.emit('event', tempBuffer);
// }, 600);
client.on('chat message', function (msg) {
console.log("receive msg=" + msg);
});
client.on('event', function (msg) {
// console.log("event", msg);
console.log("event", "send image~~");
clients.forEach(function (it) {
it.emit('event', msg)
})
});
});
io.on('disconnect', function (client) {
})
io.listen(9000);