Trying to read emitted message from the server. IE7 seems to failed..
The server code:
The server will emit "news" every half second, and disconnect after 20 news is emitted
var server = require('http').createServer();
var io = require('socket.io')(server,{
'transports':[
'polling',
'websocket',
'flashsocket',
'htmlfile'
]
});
io.on('connection', function (socket) {
console.log('connect: '+socket.id);
var num = 0;
var cInterval = setInterval(function(){
console.log(num+' emit news');
socket.emit('news', 'this is news '+num);
num++;
if(num==20) socket.disconnect();
},500);
socket.on('disconnect', function(why){
console.log('disconnect: '+socket.id);
clearInterval(cInterval);
});
});
server.listen(port,ip);
console.log('io ready');
The Client Code:
The client will log connection attempt, news content, and disconnect event.
var socket = io('ws://localhost:8080')
.on('connect',function(){
logging('connecting');
})
.on('disconnect',function(){
logging('disconnected');
})
.on('news', function (data) {
logging(data);
});
I am not using console.log as a logging mechanism so IE7 should be OK.
result in IE8,IE9, Chrome:
connecting
this is news 0
this is news 1
...
this is news 19
disconnected
result in IE7:
connecting
disconnected
Is this known?
are there any workaround(s)?
Any help would be appreciated.. Thanks..
use JSON2 as IE7 doesn't have a native JSON object. http://cdnjs.cloudflare.com/ajax/libs/json2/20130526/json2.min.js