Sha256: ffe64ff34b526a85b83123bedde7cf64c262fe72a4f4f785c42d58d085d35d71

Contents?: true

Size: 1.49 KB

Versions: 30

Compression:

Stored size: 1.49 KB

Contents

(function() {

  Luca.SocketManager = (function() {

    function SocketManager(options) {
      this.options = options != null ? options : {};
      _.extend(Backbone.Events);
      this.loadTransport();
    }

    SocketManager.prototype.connect = function() {
      switch (this.options.provider) {
        case "socket.io":
          return this.socket = io.connect(this.options.socket_host);
        case "faye.js":
          return this.socket = new Faye.Client(this.options.socket_host);
      }
    };

    SocketManager.prototype.transportLoaded = function() {
      return this.connect();
    };

    SocketManager.prototype.transport_script = function() {
      switch (this.options.provider) {
        case "socket.io":
          return "" + this.options.transport_host + "/socket.io/socket.io.js";
        case "faye.js":
          return "" + this.options.transport_host + "/faye.js";
      }
    };

    SocketManager.prototype.loadTransport = function() {
      var script,
        _this = this;
      script = document.createElement('script');
      script.setAttribute("type", "text/javascript");
      script.setAttribute("src", this.transport_script());
      script.onload = this.transportLoaded;
      if (Luca.util.isIE()) {
        script.onreadystatechange = function() {
          if (script.readyState === "loaded") return _this.transportLoaded();
        };
      }
      return document.getElementsByTagName('head')[0].appendChild(script);
    };

    return SocketManager;

  })();

}).call(this);

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
luca-0.9.76 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.9.7 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.9.65 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.9.6 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.9.42 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.9.4 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.9.2 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.9.1 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.9.0 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.8.599 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.8.59 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.8.3 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.8.2 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.8.06 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.8 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.7.92 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.7.91 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.7.9 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.7.8 vendor/assets/luca-ui/managers/socket_manager.js
luca-0.7.7 vendor/assets/luca-ui/managers/socket_manager.js