web-socket.js 和 WebSocket
我正在尝试为浏览器实现网络套接字。 Firefox、Chrome 工作得很好,但是当我在 IE 中尝试时,它会创建套接字对象但从不调用计时器。
WebSocket = function(url, protocol, proxyHost, proxyPort, headers) {
var self = this;
self.__id = WebSocket.__nextId++;
WebSocket.__instances[self.__id] = self;
self.readyState = WebSocket.CONNECTING;
self.bufferedAmount = 0;
self.__events = {};
// Uses setTimeout() to make sure __createFlash() runs after the caller sets ws.onopen etc.
// Otherwise, when onopen fires immediately, onopen is called before it is set.
setTimeout(function() {
WebSocket.__addTask(function() {
WebSocket.__flash.create(
self.__id, url, protocol, proxyHost || null, proxyPort || 0, headers || null);
});
}, 0);
};
可能是什么原因?
I am trying to do a web socket implementaton for browser. Firefox, Chrome works great, but when i try in IE, it creates the socket object but never calls the timer.
WebSocket = function(url, protocol, proxyHost, proxyPort, headers) {
var self = this;
self.__id = WebSocket.__nextId++;
WebSocket.__instances[self.__id] = self;
self.readyState = WebSocket.CONNECTING;
self.bufferedAmount = 0;
self.__events = {};
// Uses setTimeout() to make sure __createFlash() runs after the caller sets ws.onopen etc.
// Otherwise, when onopen fires immediately, onopen is called before it is set.
setTimeout(function() {
WebSocket.__addTask(function() {
WebSocket.__flash.create(
self.__id, url, protocol, proxyHost || null, proxyPort || 0, headers || null);
});
}, 0);
};
What could be the reason ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你说的是哪个版本的IE?
你使用什么 websocket 库?
旧版本的 IE 不支持 Web 套接字。我认为对于那些较旧的浏览器,您需要使用长轮询而不是 websockets...
如果您使用此: https://github.com/gimite/web-socket-js
文档中指出:
What version of IE are you talking about ?
What websocket library are you using ?
Web sockets are not supported by older version of IE. I think you need to use long polling instead of websockets for those older browsers...
If your using this : https://github.com/gimite/web-socket-js
It's stated in the Documentation :