web-socket.js and WebSocket



我正在尝试为浏览器做一个web套接字实现。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);
};

原因是什么呢?

你说的是哪个版本的IE ?你在用什么websocket库?

旧版本的IE不支持Web套接字。我认为你需要使用长轮询而不是那些旧浏览器的websockets…

如果你使用这个:https://github.com/gimite/web-socket-js在文档中有说明:

它应该工作在:谷歌Chrome 4或Later(只使用native)Firefox 3;4. x, x,Internet Explorer 8、9 + Flash Player这可能行得通,也可能行不通其他浏览器,如Safari, Opera或ie6。这些浏览器的补丁是谢谢,但我不会继续工作修复这些特定的问题我自己的浏览器。

最新更新