服务端 io.sockets.on('connection’,function(socket){
socket.on('geta’,function(data){ io.sockets.emit('dd’,{tt:58}); });
socket.on('getb’,function(data){ io.sockets.emit('ee’,{bbss:"xxdd.com"}); });
socket.on('disconnect’,function(){ console.log(“断开了”); io.sockets.emit('lossLine’,{lossLine:111}); }); });
客户端 var socket = io.connect(“http://xx.yy.com”); socket.on('connect’,function(){ socket.emit('geta’,{itemId:itemId}); socket.on('geta’,function(data){
});
socket.on('lossLine',function(data){
console.log(data);
});
});
linux 服务器上
4 debug - setting poll timeout debug - discarding transport debug - cleared close timeout for client cmDBXWPwZSXHxHtLlpdE debug - clearing poll timeout debug - xhr-polling writing 8:: debug - set close timeout for client cmDBXWPwZSXHxHtLlpdE debug - xhr-polling closed due to exceeded duration debug - setting request GET /socket.io/1/xhr-polling/cmDBXWPwZSXHxHtLlpdE?t=1375087802876 debug - setting poll timeout debug - discarding transport debug - cleared close timeout for client cmDBXWPwZSXHxHtLlpdE debug - clearing poll timeout debug - xhr-polling writing 8:: debug - set close timeout for client cmDBXWPwZSXHxHtLlpdE debug - xhr-polling closed due to exceeded duration
页面firebug 一直 自动重连 打开页面 要过二十多秒 才收到数据
页面上写了 一个onlick方法 socket.emit('getb’,{itemId:itemId}); 接受都蛮正常的