lib/js/cometio.js in sinatra-cometio-0.5.6 vs lib/js/cometio.js in sinatra-cometio-0.5.7

- old
+ new

@@ -1,9 +1,10 @@ -var CometIO = function(){ +var CometIO = function(url, opts){ new EventEmitter().apply(this); - this.url = "<%= cometio_url %>"; - this.session = null; + if(typeof opts === "undefined" || opts === null) opts = {}; + this.url = url || "<%= cometio_url %>"; + this.session = opts.session || null; var running = false; var self = this; var post_queue = []; var flush = function(){ @@ -30,11 +31,11 @@ timeout : 10000 } ); post_queue = []; }; - setInterval(flush, <%= (CometIO.options[:post_interval]*1000).to_i %>); + setInterval(flush, <%= (Sinatra::CometIO.options[:post_interval]*1000).to_i %>); this.push = function(type, data){ if(!running || !self.session){ self.emit("error", "CometIO not connected"); return; @@ -79,10 +80,10 @@ }, complete : function(e){ }, type : "GET", dataType : "json", - timeout : <%= (CometIO.options[:timeout]+10)*1000 %> + timeout : <%= (Sinatra::CometIO.options[:timeout]+10)*1000 %> } ); }; };