forked from lemonhall/douban-phantomjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
47 lines (35 loc) · 1.07 KB
/
server.js
File metadata and controls
47 lines (35 loc) · 1.07 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 app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs')
app.listen(9000);
function handler (req, res) {
fs.readFile(__dirname + '/index.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
io.sockets.on('connection', function (socket) {
//phantomjs向服务器发起这个信号
//然后服务器向所有连接过来的客户端发起
//OK,得到了一个新的验证码的信息的信号
socket.on('Got_captcha', function (data) {
//socket.emit('news', {my:"Hello"});
socket.broadcast.emit('onGot_Captach_txt',data);
});
socket.on('setFriendShip', function (data) {
//socket.emit('news', {my:"Hello"});
console.log(data);
});
// var t=setInterval(function(){
// socket.emit("hello", { my:"hello"});
// },1000);
socket.on('onGot_Captach_img', function (data) {
//socket.emit('news', {my:"Hello"});
socket.broadcast.emit('news',data);
});
});