我在socket.io v0.9上只使用了xhr-polling,但现在在1.0中我找不到这个选项。你知道antiviruse禁止websocket所以我想使用xhr-polling。我怎么能得到这个?
答案 0 :(得分:4)
有关如何在此处设置允许的socket.io传输的几个示例:https://github.com/Automattic/socket.io/wiki/configuring-socket.io
以下是一些:
var io = require('socket.io').listen(80);
io.configure('production', function(){
io.enable('browser client etag');
io.set('log level', 1);
io.set('transports', [
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]);
});
io.configure('development', function(){
io.set('transports', ['websocket']);
});
或只是这个:
// enable all transports (optional if you want flashsocket support, please note that some hosting
// providers do not allow you to create servers that listen on a port different than 80 or their
// default port)
io.set('transports', [
'xhr-polling'
]);
或者,可以在初始化服务器时设置选项:
var socket = require('socket.io').listen(80, {
// options can go here
transports: ['xhr-polling']
});