Commits

des...@fe34127c-c842-0410-aa83-9fc675b9a81c  committed bb7d0ad

recompiled Orbited.js; added a template config file; fixed the redundant reactor installation problem

  • Participants
  • Parent commits bd5f7f3
  • Branches 0.8

Comments (0)

Files changed (3)

File daemon/orbited/orbited.cfg.tmpl

+# Example Orbited Configuration file
+
+[global]
+reactor=select
+# reactor=kqueue
+# reactor=epoll
+proxy.enabled = 1
+session.ping_interval = 40
+session.ping_timeout = 30
+
+[listen]
+http://:8000
+# uncomment to enable ssl on port 8043 using given .key and .crt files
+#https://:8043
+#
+#[ssl]
+#key=orbited.key
+#crt=orbited.crt
+
+[static]
+
+[access]
+localhost:8000 -> irc.freenode.net:6667
+#* -> localhost:4747
+[logging]
+debug=STDERR,debug.log
+info=STDERR,info.log
+access=STDERR,info.log
+warn=STDERR,error.log
+error=STDERR,error.log
+
+#Don't enable debug by default
+enabled.default=info,access,warn,error
+
+# Turn debug on for the "Proxy" logger
+[loggers]
+#Proxy=debug,info,access,warn,error

File daemon/orbited/start.py

-from twisted.internet import reactor
 import config
 import logging
 import os

File daemon/orbited/static/Orbited.js

-;(function(){var preloaded_source={'jsio.std.base64':{"src":"\njsio('import jsio.logging');var logger=jsio.logging.getLogger('base64');var alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';var pad='=';var padChar=alphabet.charAt(alphabet.length-1);var shorten=function(array,number){for(var i=number;i>0;i--){array.pop();};};var decode_map={};for(var i=0,n=alphabet.length;i<n;i++){decode_map[alphabet.charAt(i)]=i;};var alphabet_inverse=new RegExp('[^'+alphabet+']');var Base64CodecError=exports.Base64CodecError=function(message){this.message=message;};Base64CodecError.prototype.toString=function(){return'Base64CodecError'+(this.message?': '+this.message:'');};var assertOrBadInput=function(exp,message){if(!exp){throw new Base64CodecError(message)};};exports.encode=function(bytes){assertOrBadInput(!(/[^\\x00-\\xFF]/.test(bytes)),'Input contains out-of-range characters.');var padding='\\x00\\x00\\x00'.slice((bytes.length%3)||3);bytes+=padding;var out_array=[];for(var i=0,n=bytes.length;i<n;i+=3){var newchars=((bytes.charCodeAt(i)<<020)+\n(bytes.charCodeAt(i+1)<<010)+\n(bytes.charCodeAt(i+2)));out_array.push(alphabet.charAt((newchars>>18)&077),alphabet.charAt((newchars>>12)&077),alphabet.charAt((newchars>>6)&077),alphabet.charAt((newchars)&077));};shorten(out_array,padding.length);return out_array.join('');};exports.decode=function(b64text){logger.debug('decode',b64text);b64text=b64text.replace(/\\s/g,'')\nvar i=b64text.length;while(b64text.charAt(--i)===pad){};b64text=b64text.slice(0,i+1);assertOrBadInput(!alphabet_inverse.test(b64text),'Input contains out-of-range characters.');var padding=Array(5-((b64text.length%4)||4)).join(padChar);b64text+=padding;var out_array=[];for(var i=0,n=b64text.length;i<n;i+=4){newchars=((decode_map[b64text.charAt(i)]<<18)+\n(decode_map[b64text.charAt(i+1)]<<12)+\n(decode_map[b64text.charAt(i+2)]<<6)+\n(decode_map[b64text.charAt(i+3)]));out_array.push((newchars>>020)&0xFF,(newchars>>010)&0xFF,(newchars)&0xFF);};shorten(out_array,padding.length);var result=String.fromCharCode.apply(String,out_array);logger.debug('decoded',result);return result;};","location":"jsio/std/base64.js"},'jsio.std.uri':{"src":"\njsio('import Class, bind')\njsio('import jsio.logging');var logger=jsio.logging.getLogger('uri');var attrs=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];exports.Uri=Class(function(supr){this.init=function(url,isStrict){var uriData=exports.parse(url,isStrict)\nfor(attr in uriData){this['_'+attr]=uriData[attr];}}\nfor(var i=0,attr;attr=attrs[i];++i){(function(attr){var fNameSuffix=attr.charAt(0).toUpperCase()+attr.slice(1);this['get'+fNameSuffix]=function(){return this['_'+attr];}\nthis['set'+fNameSuffix]=function(val){this['_'+attr]=val;}}).call(this,attr);}\nthis.toString=this.render=function(){return this._source;}});exports.buildQuery=function(kvp){var result='';for(key in kvp){result+=encodeURIComponent(key)+'='+encodeURIComponent(kvp[key])+'&';}\nreturn result;}\nvar strictRegex=/^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/;var looseRegex=/^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/;var queryStringRegex=/(?:^|&)([^&=]*)=?([^&]*)/g;exports.parse=function(str,isStrict){var regex=isStrict?strictRegex:looseRegex;var result={}\nvar match=regex.exec(str);for(var i=0,attr;attr=attrs[i];++i){result[attr]=match[i]||\"\";}\nvar qs=result['queryKey']={}\nresult['query'].replace(queryStringRegex,function(check,key,val){if(check){qs[key]=val;}})\nreturn result;}\nexports.isSameDomain=function(urlA,urlB){var a=exports.parse(urlA);var b=exports.parse(urlB);return((urlA.port==urlB.port)&&(urlA.host==urlB.host)&&(urlA.protocol=urlB.protocol))}","location":"jsio/std/uri.js"},'jsio.buffer':{"src":"\njsio('import Class, bind');jsio('import jsio.logging');jsio('from jsio.interfaces import Protocol');var logger=jsio.logging.getLogger('jsio.buffer.Buffer');var EmptyBufferError=exports.EmptyBufferError=Class(function(){this.init=function(message){this.message=message;}})\nexports.Buffer=Class(function(supr){this.init=function(rawBuffer){this._rawBuffer=!!rawBuffer?rawBuffer:\"\";}\nthis.getLength=function(){return this._rawBuffer.length;}\nthis.append=function(data){logger.info('append',JSON.stringify(data));this._rawBuffer+=data;}\nthis.peekBytes=function(num){if(!!num)\nreturn this._rawBuffer.slice(0,num);else\nreturn this._rawBuffer;}\nthis.peekToDelimiter=function(delimiter){delimiter=delimiter?delimiter:'\\n';var i=this._rawBuffer.indexOf(delimiter);if(i==-1)\nthrow new EmptyBufferError(\"delimiter \"+delmiter+\"not present in buffer\");else\nreturn this._rawBuffer.slice(0,i);}\nthis.consumeBytes=function(num){var output=this.peekBytes(num);this._rawBuffer=this._rawBuffer.slice(output.length);return output;}\nthis.consumeMaxBytes=function(num){var output=this._rawBuffer.slice(0,num);this._rawBuffer=this._rawBuffer(num);return output;}\nthis.consumeAllBytes=function(){var temp=this._rawBuffer;this._rawBuffer=\"\";return temp;}\nthis.consumeThroughDelimiter=function(delimiter){return this.consumeToDelimiter(delimiter)+this.consumeBytes(delimiter.length);}\nthis.consumeToDelimiter=function(delimiter){delimiter=!!delimiter?delimiter:\"\\n\"\nvar output=this.peekToDelimiter(delimiter);this._rawBuffer=this._rawBuffer.slice(output.length);return output;}\nthis.hasBytes=function(num){num=num?num:0;return this._rawBuffer.length>=num;}\nthis.hasDelimiter=function(delimiter){delimiter=!!delimiter?delimiter:'\\n';return(this._rawBuffer.indexOf(delimiter)!=-1);}})","location":"jsio/buffer.js"},'jsio.logging':{"src":"\njsio('import Class, bind, log');var loggers={}\nvar levels=exports.levels={DEBUG:0,LOG:1,INFO:2,WARN:3,ERROR:4};var production=false;exports.setProduction=function(prod){production=!!prod;}\nexports.getLogger=function(name){if(!(name in loggers)){loggers[name]=new exports.Logger(name);}\nreturn loggers[name];}\nexports.Logger=Class(function(){this.init=function(name,level){if(!level){level=levels.LOG;}\nthis.name=name;this.level=level;}\nthis.setLevel=function(level){this.level=level;}\nfunction makeLogFunction(level,type){return function(){if(level<this.level||production)return;log.apply(log,[type,this.name].concat(Array.prototype.slice.call(arguments,0)));}}\nthis.debug=makeLogFunction(levels.DEBUG,\"DEBUG\");this.log=makeLogFunction(levels.LOG,\"LOG\");this.info=makeLogFunction(levels.INFO,\"INFO\");this.warn=makeLogFunction(levels.WARN,\"WARN\");this.error=makeLogFunction(levels.ERROR,\"ERROR\");})","location":"jsio/logging.js"},'jsio.protocols.buffered':{"src":"\njsio('import Class, bind, jsio.logging');jsio('from jsio.interfaces import Protocol');jsio('from jsio.buffer import Buffer');var logger=jsio.logging.getLogger('Buffered');exports.BufferedProtocol=Class(Protocol,function(supr){this.init=function(){this.buffer=new Buffer();}\nthis.bufferUpdated=function(){}\nthis.dataReceived=function(data){this.buffer.append(data);this.bufferUpdated();}})","location":"jsio/protocols/buffered.js"},'jsio.env':{"src":"\njsio('import log, bind');function getObj(objectName,transportName,envName){jsio('from .env.'+(envName||jsio.__env)+'.'+transportName+' import '+objectName+' as result');return result;}\nexports.getListener=bind(this,getObj,'Listener');exports.getConnector=bind(this,getObj,'Connector');","location":"jsio/env.js"},'jsio.csp.transports':{"src":"\njsio('import Class, bind');jsio('import jsio.std.uri as uri');jsio('import jsio.std.base64 as base64');jsio('import jsio.logging');jsio('import .errors');jsio('from jsio.util.browserdetect import BrowserDetect');var logger=jsio.logging.getLogger(\"csp.transports\");exports.allTransports={};exports.registerTransport=function(name,transport){logger.debug('registering transport',name);if(name in exports.allTransports){throw new Error(\"Transport \"+name+\" already exists\");}\nexports.allTransports[name]=transport;}\nvar isLocalFile=function(url,options){var test=location.toString().match('file://');if(test&&test.index===0){logger.debug('Detected Local file');return true;};return false;};var haveCrossDomain=function(url,options){try{if(window.XDomainRequest||window.XMLHttpRequest&&(new XMLHttpRequest()).withCredentials!==undefined){logger.debug('Detected xdomain xhr capabilities');return true;}}catch(e){}\nreturn false;};var isSameDomain=function(url,options){if(uri.isSameDomain(url,location.toString())){logger.debug('Detected same domain');return true;}\nreturn false;};var canChooseXHR=function(url,options){return(!isLocalFile(url,options)||(haveCrossDomain(url,options)||isSameDomain(url,options)));};var preferXHR=function(url,options){if(canChooseXHR(url,options)){return exports.allTransports.xhr;};return exports.allTransports.jsonp;};var preferJSONP=function(url,options){return exports.allTransports.jsonp;};exports.chooseTransport=function(url,options){if(options.preferredTransport=='xhr'){return preferXHR(url,options);}else if(options.preferredTransport=='jsonp'){return preferJSONP(url,options);}else{return exports.allTransports.jsonp;}\nlogger.debug('Detected cross-domain;'+' no xdomain xhr capabilities present;'+' choosing transport jsonp');return exports.allTransports.jsonp;};var PARAMS={'xhrstream':{\"is\":\"1\",\"bs\":\"\\n\"},'xhrpoll':{\"du\":\"0\"},'xhrlongpoll':{},'sselongpoll':{\"bp\":\"data: \",\"bs\":\"\\r\\n\",\"se\":\"1\"},'ssestream':{\"bp\":\"data: \",\"bs\":\"\\r\\n\",\"se\":\"1\",\"is\":\"1\"}};exports.Transport=Class(function(supr){this.handshake=function(url,options){throw new Error(\"handshake Not Implemented\");}\nthis.comet=function(url,sessionKey,lastEventId,options){throw new Error(\"comet Not Implemented\");}\nthis.send=function(url,sessionKey,data,options){throw new Error(\"send Not Implemented\");}\nthis.encodePacket=function(packetId,data,options){throw new Error(\"encodePacket Not Implemented\");}\nthis.abort=function(){throw new Error(\"abort Not Implemented\");}});var baseTransport=Class(exports.Transport,function(supr){this.init=function(){this._handshakeArgs={d:'{}',ct:'application/javascript'};}\nthis.handshake=function(url,options){logger.debug('handshake:',url,options);this._makeRequest('send',url+'/handshake',this._handshakeArgs,this.handshakeSuccess,this.handshakeFailure);}\nthis.comet=function(url,sessionKey,lastEventId,options){logger.debug('comet:',url,sessionKey,lastEventId,options);args={s:sessionKey,a:lastEventId}\nthis._makeRequest('comet',url+'/comet',args,this.cometSuccess,this.cometFailure);}\nthis.send=function(url,sessionKey,data,options){logger.debug('send:',url,sessionKey,data,options);args={d:data,s:sessionKey}\nthis._makeRequest('send',url+'/send',args,this.sendSuccess,this.sendFailure);}});exports.registerTransport('xhr',Class(baseTransport,function(supr){var createXHR=function(){return window.XMLHttpRequest?new XMLHttpRequest():window.XDomainRequest?new XDomainRequest():window.ActiveXObject?new ActiveXObject(\"Msxml2.XMLHTTP\"):null;}\nvar abortXHR=function(xhr){logger.debug('aborting XHR');try{if('onload'in xhr){xhr.onload=xhr.onerror=null;}else if('onreadystatechange'in xhr){xhr.onreadystatechange=null;}\nif(xhr.abort){xhr.abort();}}catch(e){logger.debug('error aborting xhr',e);}}\nthis.init=function(){supr(this,'init');this._xhr={'send':createXHR(),'comet':createXHR()};}\nthis.abort=function(){var xhr;for(var i in this._xhr){if(this._xhr.hasOwnProperty(i)){abortXHR(xhr);}}}\nthis.encodePacket=function(packetId,data,options){return data.indexOf('\\0')==-1?[packetId,0,data]:[packetId,1,base64.encode(data)];}\nthis._onReadyStateChange=function(rType,cb,eb){try{var xhr=this._xhr[rType];if(xhr.readyState!=4){return;}\nif(xhr.status!=200){logger.debug('XHR failed with status ',xhr.status);eb();}\nlogger.debug('XHR data received');cb(eval(xhr.responseText));}catch(e){var xhr=this._xhr[rType];logger.debug('Error in XHR::onReadyStateChange',e);eb();abortXHR(xhr);logger.debug('done handling XHR error');}}\nthis._makeRequest=function(rType,url,args,cb,eb){var xhr=this._xhr[rType],data=args.d||null;if('d'in args){delete args.d;}\nxhr.open('POST',url+'?'+uri.buildQuery(args));xhr.setRequestHeader('Content-Type','text/plain');if('onload'in xhr){xhr.onload=bind(this,'_onReadyStateChange',rType,cb,eb);xhr.onerror=xhr.ontimeout=eb;}else if('onreadystatechange'in xhr){xhr.onreadystatechange=bind(this,'_onReadyStateChange',rType,cb,eb);}\nif(data){xhr.send(data);}else{xhr.send();}}}));exports.registerTransport('jsonp',Class(baseTransport,function(supr){var logger=jsio.logging.getLogger('csp.transports.jsonp');var createIframe=function(){var i=document.createElement(\"iframe\");with(i.style){display='block';width=height=border=margin=padding='0';overflow=visibility='hidden';}\ni.cbId=0;i.src='javascript:document.open();document.write(\"<html><body></body></html>\")';document.body.appendChild(i);return i;}\nvar abortIframe=function(ifr){var win=ifr.contentWindow,doc=win.document;logger.debug('removing scripts');var scripts=doc.getElementsByTagName('script');var s1=doc.getElementsByTagName('script')[0];var s2=doc.getElementsByTagName('script')[1];if(s1)s1.parentNode.removeChild(s1);if(s2)s2.parentNode.removeChild(s2);logger.debug('removed scripts');logger.debug('deleting callbacks');win['cb'+(ifr.cbId-1)]=function(){};win['eb'+(ifr.cbId-1)]=function(){};}\nvar removeIframe=function(ifr){$setTimeout(function(){if(ifr&&ifr.parentNode){ifr.parentNode.removeChild(ifr);}},60000);}\nthis.init=function(){supr(this,'init');this._onReady=[];this._isReady=false;this._createIframes();}\nthis._createIframes=function(){if(!document.body){setTimeout(bind(this,'_createIframes'),100);return;}\nthis._isReady=true;this._ifr={'send':createIframe(),'comet':createIframe()};var readyArgs=this._onReady;this._onReady=[];for(var i=0,args;args=readyArgs[i];++i){this._makeRequest.apply(this,args);}}\nthis.encodePacket=function(packetId,data,options){return[packetId,1,base64.encode(data)];}\nthis.abort=function(){for(var i in this._ifr){if(this._ifr.hasOwnProperty(i)){var ifr=this._ifr[i];abortIframe(ifr);removeIframe(ifr);}}}\nthis._makeRequest=function(rType,url,args,cb,eb){if(!this._isReady){this._onReady.push(arguments);return;}\nargs.n=Math.random();$setTimeout(bind(this,function(){var ifr=this._ifr[rType];var win=ifr.contentWindow,doc=win.document,body=doc.body;var completed=false;var jsonpId=ifr.cbId++;var onFinish=win['eb'+jsonpId]=function(scriptTag){if(scriptTag&&scriptTag.readyState!='loaded'){return;}\nlogger.debug('in onFinish');if(!completed){logger.debug('error making request:',fullUrl);}\nabortIframe(ifr);if(!completed){logger.debug('calling eb');eb.apply(null,arguments);}}\nwin['cb'+jsonpId]=function callback(){logger.debug('successful: ',fullUrl,[].slice.call(arguments,0));completed=true;logger.debug('calling the cb');cb.apply(null,arguments);logger.debug('cb called');}\nswitch(rType){case'send':args.rs=';';args.rp='cb'+jsonpId;break;case'comet':args.bs=';';args.bp='cb'+jsonpId;break;}\nvar fullUrl=url+'?'+uri.buildQuery(args);if(BrowserDetect.isWebKit){doc.open();doc.write('<scr'+'ipt src=\"'+fullUrl+'\"></scr'+'ipt>');doc.write('<scr'+'ipt>eb'+jsonpId+'(false)</scr'+'ipt>');}else{var s=doc.createElement('script');s.src=fullUrl;if(s.onreadystatechange===null){s.onreadystatechange=bind(window,onFinish,s);}\nbody.appendChild(s);if(!BrowserDetect.isIE){var s=doc.createElement('script');s.innerHTML='eb'+jsonpId+'(false)';body.appendChild(s);}}\nkillLoadingBar();}),0);}\nfunction killLoadingBar(){}}));","location":"jsio/csp/transports.js"},'jsio.interfaces':{"src":"\njsio('import Class, bind');exports.Protocol=Class(function(){this.connectionMade=function(isReconnect){}\nthis.dataReceived=function(data){}\nthis.connectionLost=function(reason){}\nthis.connectionFailed=function(){}});exports.Server=Class(function(){this.init=function(protocolClass){this._protocolClass=protocolClass;}\nthis.buildProtocol=function(){return new this._protocolClass();}});exports.Transport=Class(function(){this.write=function(data,encoding){throw new Error(\"Not implemented\");}\nthis.getPeer=function(){throw new Error(\"Not implemented\");}});exports.Listener=Class(function(){this.init=function(server,opts){this._server=server;this._opts=opts||{};}\nthis.onConnect=function(transport){var p=this._server.buildProtocol();p.transport=transport;p.server=this._server;transport.protocol=p;transport.makeConnection(p);p.connectionMade();}\nthis.listen=function(){throw new Error('Abstract class');}\nthis.stop=function(){}});exports.Connector=Class(function(){this.init=function(protocol,opts){this._protocol=protocol;this._opts=opts;}\nthis.onConnect=function(transport){transport.makeConnection(this._protocol);this._protocol.transport=transport;this._protocol.connectionMade();}\nthis.getProtocol=function(){return this._protocol;}});exports.PubSub=Class(function(){this.publish=function(signal){if(!this._subscribers){return;}\nvar args=Array.prototype.slice.call(arguments,1);if(this._subscribers.__any){var anyArgs=[signal].concat(args);for(var i=0,sub;sub=this._subscribers.__any[i];++i){sub.apply(window,args);}}\nif(!this._subscribers[signal]){return;}\nfor(var i=0,sub;sub=this._subscribers[signal][i];++i){sub.apply(window,args);}}\nthis.subscribe=function(signal){if(!this._subscribers){this._subscribers={};}\nif(!this._subscribers[signal]){this._subscribers[signal]=[];}\nthis._subscribers[signal].push(bind.apply(jsio,Array.prototype.slice.call(arguments,1)));}});","location":"jsio/interfaces.js"},'jsio.csp.client':{"src":"\njsio('import jsio.std.base64 as base64');jsio('import jsio.std.utf8 as utf8');jsio('import jsio.std.uri as uri');jsio('import jsio.logging');jsio('import .errors');jsio('import .transports');var logger=jsio.logging.getLogger(\"csp.client\");var READYSTATE=exports.READYSTATE={INITIAL:0,CONNECTING:1,CONNECTED:2,DISCONNECTING:3,DISCONNECTED:4};exports.CometSession=Class(function(supr){var id=0;var kDefaultBackoff=50;var kDefaultTimeoutInterval=45000;var kDefaultHandshakeTimeout=10000;this.init=function(){this._id=++id;this._url=null;this.readyState=READYSTATE.INITIAL;this._sessionKey=null;this._transport=null;this._options=null;this._utf8ReadBuffer=\"\";this._writeBuffer=\"\";this._packetsInFlight=null;this._lastEventId=null;this._lastSentId=null;this._handshakeLater=null;this._handshakeBackoff=kDefaultBackoff;this._handshakeRetryTimer=null;this._handshakeTimeoutTimer=null;this._timeoutTimer=null;this._writeBackoff=kDefaultBackoff;this._writeRetryTimer=null;this.cometBackoff=kDefaultBackoff;this._cometRetryTimer=null;}\nthis.setEncoding=function(encoding){if(encoding==this._options.encoding){return;}\nif(encoding!='utf8'&&encoding!='plain'){throw new errors.InvalidEncodingError();}\nif(encoding=='plain'&&this._buffer){var buffer=this._utf8ReadBuffer;this._utf8ReadBuffer=\"\";this._doOnRead(buffer);}\nthis._options.encoding=encoding;}\nthis.connect=function(url,options){this._url=url;this._options=options||{};this._options.encoding=this._options.encoding||'utf8';this.setEncoding(this._options.encoding);this._options.connectTimeout=this._options.connectTimeout||kDefaultHandshakeTimeout;var transportClass=transports.chooseTransport(url,this._options);this._transport=new transportClass();this._transport.handshakeFailure=bind(this,this._handshakeFailure);this._transport.handshakeSuccess=bind(this,this._handshakeSuccess);this._transport.cometFailure=bind(this,this._cometFailure);this._transport.cometSuccess=bind(this,this._cometSuccess);this._transport.sendFailure=bind(this,this._writeFailure);this._transport.sendSuccess=bind(this,this._writeSuccess);this.readyState=READYSTATE.CONNECTING;this._transport.handshake(this._url,this._options);this._handshakeTimeoutTimer=$setTimeout(bind(this,this._handshakeTimeout),this._options.connectTimeout);}\nthis.write=function(data,encoding){if(this.readyState!=READYSTATE.CONNECTED){throw new errors.ReadyStateError();}\nencoding=encoding||this._options.encoding||'utf8';if(encoding=='utf8'){data=utf8.encode(data);}\nthis._writeBuffer+=data;this._doWrite();}\nthis.close=function(err){switch(this.readyState){case READYSTATE.CONNECTING:clearTimeout(this._handshakeRetryTimer);clearTimeout(this._handshakeTimeoutTimer);break;case READYSTATE.CONNECTED:this._transport.abort();clearTimeout(this._cometRetryTimer);clearTimeout(this._writeRetryTimer);clearTimeout(this._timeoutTimer);break;case READYSTATE.DISCONNECTED:throw new errors.ReadyStateError(\"Session is already disconnected\");break;}\nthis._doOnDisconnect(err);}\nthis._handshakeTimeout=function(){logger.debug('handshake timeout');this._handshakeTimeoutTimer=null;this._doOnDisconnect(new errors.HandshakeTimeout());}\nthis._handshakeSuccess=function(d){logger.debug('handshake success',d);if(this.readyState!=READYSTATE.CONNECTING){logger.debug('received handshake success in invalid readyState:',this.readyState);return;}\nclearTimeout(this._handshakeTimeoutTimer);this._handshakeTimeoutTimer=null;this._sessionKey=d.session;this._opened=true;this.readyState=READYSTATE.CONNECTED;this._doOnConnect();this._doConnectComet();}\nthis._handshakeFailure=function(e){logger.debug('handshake failure',e);if(this.readyState!=READYSTATE.CONNECTING){return;}\nlogger.debug('trying again in ',this._handshakeBackoff);this._handshakeRetryTimer=$setTimeout(bind(this,function(){this._handshakeRetryTimer=null;this._transport.handshake(this._url,this._options);}),this._handshakeBackoff);this._handshakeBackoff*=2;}\nthis._writeSuccess=function(){if(this.readyState!=READYSTATE.CONNECTED){return;}\nthis._resetTimeoutTimer();this.writeBackoff=kDefaultBackoff;this._packetsInFlight=null;if(this._writeBuffer){this._doWrite();}}\nthis._writeFailure=function(){if(this.readyState!=READYSTATE.CONNECTED){return;}\nthis._writeTimer=$setTimeout(bind(this,function(){this._writeTimer=null;this._doWrite();}),this._writeBackoff);this._writeBackoff*=2;}\nthis._doWrite=function(){if(this._packetsInFlight){return;}\nlogger.debug('_writeBuffer:',this._writeBuffer);this._packetsInFlight=[this._transport.encodePacket(++this._lastSentId,this._writeBuffer,this._options)];this._writeBuffer=\"\";logger.debug('sending packets:',JSON.stringify(this._packetsInFlight));this._transport.send(this._url,this._sessionKey,JSON.stringify(this._packetsInFlight),this._options);}\nthis._doConnectComet=function(){logger.debug('_doConnectComet');this._transport.comet(this._url,this._sessionKey,this._lastEventId||0,this._options);}\nthis._cometFailure=function(){if(this.readyState!=READYSTATE.CONNECTED){return;}\nthis._cometTimer=$setTimeout(bind(this,function(){this._doConnectComet();}),this._cometBackoff);this._cometBackoff*=2;}\nthis._cometSuccess=function(packets){if(this.readyState!=READYSTATE.CONNECTED){return;}\nlogger.debug('comet Success:',packets);this._cometBackoff=kDefaultBackoff;this._resetTimeoutTimer();for(var i=0,packet;(packet=packets[i])||i<packets.length;i++){logger.debug('process packet:',packet);if(packet===null){return self.close();}\nlogger.debug('process packet',packet);var ackId=packet[0];var encoding=packet[1];var data=packet[2];if(typeof(this._lastEventId)=='number'&&ackId<=this._lastEventId){continue;}\nif(typeof(this._lastEventId)=='number'&&ackId!=this._lastEventId+1){return this.close(new errors.ServerProtocolError(201));}\nthis._lastEventId=ackId;if(encoding==1){try{logger.debug('before base64 decode:',data);data=base64.decode(data);logger.debug('after base64 decode:',data);}catch(e){return this.close(new errors.ServerProtocolError(202));}}\nif(this._options.encoding=='utf8'){this._utf8ReadBuffer+=data;logger.debug('before utf8 decode, _utf8ReadBuffer:',this._utf8ReadBuffer);var result=utf8.decode(this._utf8ReadBuffer);data=result[0];this._utf8ReadBuffer=this._utf8ReadBuffer.slice(result[1]);logger.debug('after utf8 decode, _utf8ReadBuffer:',this._utf8ReadBuffer,'data:',data);}\nlogger.debug('dispatching data:',data);try{this._doOnRead(data);}catch(e){logger.error('application code threw an error. (re-throwing in timeout):',e);setTimeout(function(){logger.debug('timeout fired, throwing error',e);throw e;},0);}}\nthis._doConnectComet();}\nthis._doOnRead=function(data){if(typeof(this.onread)=='function'){logger.debug('call onread function',data);this.onread(data);}\nelse{logger.debug('skipping onread callback (function missing)');}}\nthis._doOnDisconnect=function(err){if(typeof(this.ondisconnect)=='function'){logger.debug('call ondisconnect function',err);this.ondisconnect(err);}\nelse{logger.debug('skipping ondisconnect callback (function missing)');}}\nthis._doOnConnect=function(){if(typeof(this.onconnect)=='function'){logger.debug('call onconnect function');try{this.onconnect();}catch(e){logger.debug('onconnect caused errror',e);setTimeout(function(){throw e},0);}}\nelse{logger.debug('skipping onconnect callback (function missing)');}}\nthis._resetTimeoutTimer=function(){clearTimeout(this._timeoutTimer);this._timeoutTimer=$setTimeout(bind(this,function(){logger.debug('connection timeout expired');this.close(new errors.SessionTimeout())}),this._getTimeoutInterval())}\nthis._getTimeoutInterval=function(){return kDefaultTimeoutInterval;}});","location":"jsio/csp/client.js"},'jsio.protocols.mspp':{"src":"\njsio('import Class, log, jsio.logging');jsio('import jsio.std.utf8 as utf8');jsio('from jsio.protocols.buffered import BufferedProtocol');var loggers={};loggers.stream=jsio.logging.getLogger('MSPPStream');loggers.protocol=jsio.logging.getLogger('MSPPProtocol');loggers.stream.setLevel(0);loggers.protocol.setLevel(0);var frames={'OPEN':0,'CLOSE':1,'DATA':2};exports.MSPPStream=Class(function(){this.setMultiplexer=function(multiplexer){loggers.stream.debug('setMultiplexer: '+multiplexer);this.multiplexer=multiplexer;}\nthis.setEncoding=function(encoding){loggers.stream.debug('setEncoding: '+encoding);this.encoding=encoding;}\nthis.open=function(host,port,isBinary){if(isBinary)\nthis.encoding='utf8';this.id=this.multiplexer.openStream(this,host,port);loggers.stream.debug('open '+this.id+\": \"+host+\" \"+port+\" \"+isBinary);}\nthis.close=function(){loggers.stream.debug('close '+this.id);this.multiplexer.close(this.id);}\nthis.send=function(data,encoding){loggers.stream.debug('send '+this.id+\": \"+data+\" \"+encoding);if((encoding||this.encoding)=='utf8')\ndata=utf8.encode(data);this.multiplexer.writeToStream(this.id,data);}\nthis._onreadraw=function(data){if(this.encoding=='utf8')\ndata=utf8.decode(data);loggers.stream.debug('_onreadraw '+data);this.onread(data);}\nthis.onopen=function(){}\nthis.onclose=function(err){}\nthis.onread=function(data){}});var state={};state.closed=0;state.connecting=1;state.consuming=2;exports.MSPPProtocol=Class(BufferedProtocol,function(supr){this.init=function(){loggers.protocol.debug('new MSPPProtocol');supr(this,'init',[]);this.state=state.closed;this.transportType=null;this.transportOptions=null;this.currentId=0;this.streams={};this.writeBuffer=[];}\nthis.setTransport=function(transportType,transportOptions){this.transportType=transportType;this.transportOptions=transportOptions;}\nthis.connectionMade=function(isReconnect){loggers.protocol.debug('connectionMade');this.state=state.consuming;for(var i=0;i<this.writeBuffer.length;i++)\nthis._write(this.writeBuffer[i]);writeBuffer=[];}\nthis.connectionLost=this.connectionFailed=function(reason){loggers.protocol.debug('closed: '+reason);this.state=state.closed;for(stream in this.streams)\nthis.streams[stream].onclose(reason);}\nthis.openStream=function(stream,host,port){if(this.state==state.closed){this.state=state.connecting;jsio.connect(this,this.transportType,this.transportOptions);}\nvar id=++this.currentId;this.streams[id]=stream;this._write([id,frames.OPEN,host+\",\"+port]);return id;}\nthis.closeStream=function(id){this._write([id,frames.CLOSE,\"\"]);}\nthis.writeToStream=function(id,data){this._write([id,frames.DATA,data]);}\nthis.bufferUpdated=function(){loggers.protocol.debug(\"bufferUpdated. state: \"+this.state+\". buffer: \"+this.buffer._rawBuffer);if(this.state!=state.consuming)\nthrow new Error(\"buffer update in invalid MSPP state: \"+this.state);if(!this.buffer.hasDelimiter(':'))\nreturn;var lStr=this.buffer.peekToDelimiter(':');var len=parseInt(lStr);if(!this.buffer.hasBytes(len+lStr.length+1))\nreturn;this.buffer.consumeThroughDelimiter(':');var streamId=this.buffer.consumeToDelimiter(',');this.buffer.consumeBytes(1);var frameType=parseInt(this.buffer.consumeBytes(1));len-=(streamId.length+2);streamId=parseInt(streamId);var data=this.buffer.consumeBytes(len);switch(frameType){case frames.OPEN:this.streams[streamId].onopen();break;case frames.CLOSE:this.streams[streamId].onclose(data);break;case frames.DATA:this.streams[streamId]._onreadraw(data);break;default:throw new Error('invalid MSPP data type!');}}\nthis._write=function(data){if(this.state!=state.consuming){loggers.protocol.debug(\"buffering write: \"+data);this.writeBuffer.push(data);return;}\nvar s=data[0]+\",\"+data[1]+data[2];s=s.length+\":\"+s;loggers.protocol.debug('write: '+s);this.transport.write(s);}});","location":"jsio/protocols/mspp.js"},'jsio.csp.errors':{"src":"\nvar makeErrorClass=function(name,_code){var out=function(message,code){this.message=message;this.code=code||_code;}\nout.prototype.toString=function(){return name+(this.message?': '+this.message:'');}\nreturn out;}\nexports.ReadyStateError=makeErrorClass(\"ReadyStateError\");exports.InvalidEncodingError=makeErrorClass(\"InvalidEncodingError\");exports.HandshakeTimeout=makeErrorClass(\"HandshakeTimeout\",100);exports.SessionTimeout=makeErrorClass(\"HandshakeTimeout\",101);exports.ServerProtocolError=makeErrorClass(\"ServerProtocolError\",200);","location":"jsio/csp/errors.js"},'Orbited':{"src":"\njsio('import Class');jsio('from jsio.protocols.mspp import MSPPStream, MSPPProtocol');var multiplexer=null;exports.settings={'host':'localhost','port':8000,'path':'/csp'};exports.TCPSocket=Class(MSPPStream,function(){this.init=function(){this.setEncoding('plain');if(multiplexer==null){multiplexer=new MSPPProtocol();multiplexer.setTransport('csp',{\"url\":\"http://\"+exports.settings.host+\":\"+exports.settings.port+exports.settings.path});}\nthis.setMultiplexer(multiplexer);}});","location":"Orbited.js"},'jsio.std.JSON':{"src":"\nexports.createGlobal=function(){if(typeof JSON=='undefined'){JSON={};}\nif(typeof JSON.stringify!=='function'){JSON.stringify=exports.stringify;}\nif(typeof JSON.parse!=='function'){JSON.parse=exports.parse;}};;(function(){var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={'\\b':'\\\\b','\\t':'\\\\t','\\n':'\\\\n','\\f':'\\\\f','\\r':'\\\\r','\"':'\\\\\"','\\\\':'\\\\\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'\"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'\"':'\"'+string+'\"';}\nfunction str(key,holder){var mind=gap,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}\nif(typeof rep==='function'){value=rep.call(holder,key,value);}\nswitch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':return String(value);case'object':if(value===null){return'null';}\nif(value.constructor===Date){return exports.stringifyDate(value);}\ngap+=indent;var partial=[];if(value.constructor===Array){var length=value.length;for(var i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}\nvar v=partial.length===0?'[]':gap?'[\\n'+gap+\npartial.join(',\\n'+gap)+'\\n'+\nmind+']':'['+partial.join(',')+']';gap=mind;return v;}\nif(rep&&typeof rep==='object'){var length=rep.length;for(var i=0;i<length;i+=1){var k=rep[i];if(typeof k==='string'){var v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(var k in value){if(Object.hasOwnProperty.call(value,k)){var v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}\nvar v=partial.length===0?'{}':gap?'{\\n'+gap+partial.join(',\\n'+gap)+'\\n'+\nmind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}\nexports.stringify=function(value,replacer,space){gap='';indent='';if(typeof space==='number'){for(var i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}\nrep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON stringify: invalid replacer');}\nreturn str('',{'':value});};exports.stringifyDate=function(d){var year=d.getUTCFullYear(),month=d.getUTCMonth()+1,day=d.getUTCDate(),hours=d.getUTCHours(),minutes=d.getUTCMinutes(),seconds=d.getUTCSeconds(),ms=d.getUTCMilliseconds();if(month<10){month='0'+month;}\nif(day<10){day='0'+day;}\nif(hours<10){hours='0'+hours;}\nif(minutes<10){minutes='0'+minutes;}\nif(seconds<10){seconds='0'+seconds;}\nif(ms<10){ms='00'+ms;}\nelse if(ms<100){ms='0'+ms;}\nreturn'\"'+year\n+'-'+month\n+'-'+day\n+'T'+hours\n+':'+minutes\n+':'+seconds\n+'.'+ms\n+'Z\"';}\nexports.parse=function(text,reviver){cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\\\u'+\n('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}\nif(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,']').replace(/(?:^|:|,)(?:\\s*\\[)+/g,'')))\n{var j=eval('('+text+')');if(!reviver){return j;}else{var walk=function(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}\nreturn reviver.call(holder,key,value);}\nreturn walk({'':j},'');}}\nthrow new SyntaxError('JSON.parse');};}());","location":"jsio/std/JSON.js"},'jsio.env.browser.csp':{"src":"\njsio('import Class, bind, jsio.logging, jsio.interfaces');jsio('from jsio.csp.client import CometSession');var logger=jsio.logging.getLogger('env.browser.csp');exports.Connector=Class(jsio.interfaces.Connector,function(){this.connect=function(){var conn=new CometSession();conn.onconnect=bind(this,function(){logger.debug('conn has opened');this.onConnect(new Transport(conn));});conn.ondisconnect=bind(this,function(code){logger.debug('conn closed without opening, code:',code);});logger.debug('open the conection');this._opts.encoding='plain';var url=this._opts.url;delete this._opts.url;conn.connect(url,this._opts);}});var Transport=Class(jsio.interfaces.Transport,function(){this.init=function(conn){this._conn=conn;}\nthis.makeConnection=function(protocol){this._conn.onread=bind(protocol,'dataReceived');this._conn.ondisconnect=bind(protocol,'connectionLost');}\nthis.write=function(data,encoding){this._conn.write(data);}\nthis.loseConnection=function(protocol){this._conn.close();}});","location":"jsio/env/browser/csp.js"},'jsio.std.utf8':{"src":"\nexports.UnicodeCodecError=function(message){this.message=message;};var UnicodeCodecError=exports.UnicodeCodecError;UnicodeCodecError.prototype.toString=function(){return'UnicodeCodecError'+(this.message?': '+this.message:'');};exports.encode=function(unicode_string){try{return unescape(encodeURIComponent(unicode_string));}\ncatch(err){throw new UnicodeCodecError('invalid input string');};};exports.decode=function(bytes){if(/[^\\x00-\\xFF]/.test(bytes)){throw new UnicodeCodecError('invalid utf-8 bytes');};var len,len_parsed;len=len_parsed=bytes.length;var last=len-1;if(bytes.charCodeAt(last)>=0x80){for(var i=1;i<=3;i++){if(bytes.charCodeAt(len-i)>=0xC0){len_parsed=len-i;break;};};try{decodeURIComponent(escape(bytes.slice(len_parsed)));len_parsed=len;}\ncatch(err){};};try{return[decodeURIComponent(escape(bytes.slice(0,len_parsed))),len_parsed];}\ncatch(err){throw new UnicodeCodecError('invalid utf-8 bytes');};};","location":"jsio/std/utf8.js"},'jsio.util.browserdetect':{"src":"\nexports.BrowserDetect=new function(){var versionSearchString;var dataBrowser=[{string:navigator.userAgent,subString:\"Chrome\"},{string:navigator.userAgent,subString:\"OmniWeb\",versionSearch:\"OmniWeb/\"},{string:navigator.vendor,subString:\"Apple\",identity:\"Safari\",versionSearch:\"Version\"},{prop:window.opera,identity:\"Opera\"},{string:navigator.vendor,subString:\"iCab\"},{string:navigator.vendor,subString:\"KDE\",identity:\"Konqueror\"},{string:navigator.userAgent,subString:\"Firefox\"},{string:navigator.vendor,subString:\"Camino\"},{string:navigator.userAgent,subString:\"Netscape\"},{string:navigator.userAgent,subString:\"MSIE\",identity:\"IE\",versionSearch:\"MSIE\"},{string:navigator.userAgent,subString:\"Gecko\",identity:\"Mozilla\",versionSearch:\"rv\"},{string:navigator.userAgent,subString:\"Mozilla\",identity:\"Netscape\",versionSearch:\"Mozilla\"}];var dataOS=[{string:navigator.platform,subString:\"Win\",identity:\"Windows\"},{string:navigator.platform,subString:\"Mac\"},{string:navigator.userAgent,subString:\"iPhone\",identity:\"iPhone/iPod\"},{string:navigator.platform,subString:\"Linux\"}];function searchString(data){for(var i=0,item;item=data[i];i++){var dataString=item.string;var dataProp=item.prop;item.identity=item.identity||item.subString;versionSearchString=item.versionSearch||item.identity;if(dataString){if(dataString.indexOf(item.subString)!=-1)\nreturn item.identity;}else if(dataProp)\nreturn item.identity;}}\nfunction searchVersion(dataString){var index=dataString.indexOf(versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+versionSearchString.length+1));}\nthis.browser=searchString(dataBrowser)||\"unknown\";this.version=searchVersion(navigator.userAgent)||searchVersion(navigator.appVersion)||\"unknown\";this.OS=searchString(dataOS)||\"unknown\";this.isWebKit=RegExp(\" AppleWebKit/\").test(navigator.userAgent);this['is'+this.browser]=this.version;};","location":"jsio/util/browserdetect.js"}};var pre_jsioImport=[];if(typeof exports=='undefined'){var jsio=window.jsio=bind(this,_jsioImport,window,'');}else if(typeof GLOBAL!='undefined'){var jsio=GLOBAL.jsio=bind(this,_jsioImport,GLOBAL,'');}
+;(function(){var preloaded_source={'jsio.std.base64':{"src":"\njsio('import jsio.logging');var logger=jsio.logging.getLogger('base64');var alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\\\\-_';var pad='=';var padChar=alphabet.charAt(alphabet.length-1);var shorten=function(array,number){for(var i=number;i>0;i--){array.pop();};};var decode_map={};for(var i=0,n=alphabet.length;i<n;i++){decode_map[alphabet.charAt(i)]=i;};var alphabet_inverse=new RegExp('[^'+alphabet.replace('-','\\\\-')+']');var Base64CodecError=exports.Base64CodecError=function(message){this.message=message;};Base64CodecError.prototype.toString=function(){return'Base64CodecError'+(this.message?': '+this.message:'');};var assertOrBadInput=function(exp,message){if(!exp){throw new Base64CodecError(message)};};exports.encode=function(bytes){assertOrBadInput(!(/[^\\x00-\\xFF]/.test(bytes)),'Input contains out-of-range characters.');var padding='\\x00\\x00\\x00'.slice((bytes.length%3)||3);bytes+=padding;var out_array=[];for(var i=0,n=bytes.length;i<n;i+=3){var newchars=((bytes.charCodeAt(i)<<020)+\n(bytes.charCodeAt(i+1)<<010)+\n(bytes.charCodeAt(i+2)));out_array.push(alphabet.charAt((newchars>>18)&077),alphabet.charAt((newchars>>12)&077),alphabet.charAt((newchars>>6)&077),alphabet.charAt((newchars)&077));};shorten(out_array,padding.length);return out_array.join('');};exports.decode=function(b64text){logger.debug('decode',b64text);b64text=b64text.replace(/\\s/g,'')\nvar i=b64text.length;while(b64text.charAt(--i)===pad){};b64text=b64text.slice(0,i+1);assertOrBadInput(!alphabet_inverse.test(b64text),'Input contains out-of-range characters.');var padding=Array(5-((b64text.length%4)||4)).join(padChar);b64text+=padding;var out_array=[];for(var i=0,n=b64text.length;i<n;i+=4){newchars=((decode_map[b64text.charAt(i)]<<18)+\n(decode_map[b64text.charAt(i+1)]<<12)+\n(decode_map[b64text.charAt(i+2)]<<6)+\n(decode_map[b64text.charAt(i+3)]));out_array.push((newchars>>020)&0xFF,(newchars>>010)&0xFF,(newchars)&0xFF);};shorten(out_array,padding.length);var result=String.fromCharCode.apply(String,out_array);logger.debug('decoded',result);return result;};","location":"jsio/std/base64.js"},'jsio.std.uri':{"src":"\njsio('import Class, bind')\njsio('import jsio.logging');var logger=jsio.logging.getLogger('uri');var attrs=[\"source\",\"protocol\",\"authority\",\"userInfo\",\"user\",\"password\",\"host\",\"port\",\"relative\",\"path\",\"directory\",\"file\",\"query\",\"anchor\"];exports.Uri=Class(function(supr){this.init=function(url,isStrict){var uriData=exports.parse(url,isStrict)\nfor(attr in uriData){this['_'+attr]=uriData[attr];}}\nfor(var i=0,attr;attr=attrs[i];++i){(function(attr){var fNameSuffix=attr.charAt(0).toUpperCase()+attr.slice(1);this['get'+fNameSuffix]=function(){return this['_'+attr];}\nthis['set'+fNameSuffix]=function(val){this['_'+attr]=val;}}).call(this,attr);}\nthis.toString=this.render=function(){return this._source;}});exports.buildQuery=function(kvp){var result='';for(key in kvp){result+=encodeURIComponent(key)+'='+encodeURIComponent(kvp[key])+'&';}\nreturn result;}\nvar strictRegex=/^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/;var looseRegex=/^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/;var queryStringRegex=/(?:^|&)([^&=]*)=?([^&]*)/g;exports.parse=function(str,isStrict){var regex=isStrict?strictRegex:looseRegex;var result={}\nvar match=regex.exec(str);for(var i=0,attr;attr=attrs[i];++i){result[attr]=match[i]||\"\";}\nvar qs=result['queryKey']={}\nresult['query'].replace(queryStringRegex,function(check,key,val){if(check){qs[key]=val;}})\nreturn result;}\nexports.isSameDomain=function(urlA,urlB){var a=exports.parse(urlA);var b=exports.parse(urlB);return((urlA.port==urlB.port)&&(urlA.host==urlB.host)&&(urlA.protocol=urlB.protocol))}","location":"jsio/std/uri.js"},'jsio.buffer':{"src":"\njsio('import Class, bind');jsio('import jsio.logging');jsio('from jsio.interfaces import Protocol');var logger=jsio.logging.getLogger('jsio.buffer.Buffer');var EmptyBufferError=exports.EmptyBufferError=Class(function(){this.init=function(message){this.message=message;}})\nexports.Buffer=Class(function(supr){this.init=function(rawBuffer){this._rawBuffer=!!rawBuffer?rawBuffer:\"\";}\nthis.getLength=function(){return this._rawBuffer.length;}\nthis.append=function(data){logger.info('append',JSON.stringify(data));this._rawBuffer+=data;}\nthis.peekBytes=function(num){if(!!num)\nreturn this._rawBuffer.slice(0,num);else\nreturn this._rawBuffer;}\nthis.peekToDelimiter=function(delimiter){delimiter=delimiter?delimiter:'\\n';var i=this._rawBuffer.indexOf(delimiter);if(i==-1)\nthrow new EmptyBufferError(\"delimiter \"+delmiter+\"not present in buffer\");else\nreturn this._rawBuffer.slice(0,i);}\nthis.consumeBytes=function(num){var output=this.peekBytes(num);this._rawBuffer=this._rawBuffer.slice(output.length);return output;}\nthis.consumeMaxBytes=function(num){var output=this._rawBuffer.slice(0,num);this._rawBuffer=this._rawBuffer(num);return output;}\nthis.consumeAllBytes=function(){var temp=this._rawBuffer;this._rawBuffer=\"\";return temp;}\nthis.consumeThroughDelimiter=function(delimiter){return this.consumeToDelimiter(delimiter)+this.consumeBytes(delimiter.length);}\nthis.consumeToDelimiter=function(delimiter){delimiter=!!delimiter?delimiter:\"\\n\"\nvar output=this.peekToDelimiter(delimiter);this._rawBuffer=this._rawBuffer.slice(output.length);return output;}\nthis.hasBytes=function(num){num=num?num:0;return this._rawBuffer.length>=num;}\nthis.hasDelimiter=function(delimiter){delimiter=!!delimiter?delimiter:'\\n';return(this._rawBuffer.indexOf(delimiter)!=-1);}})","location":"jsio/buffer.js"},'jsio.logging':{"src":"\njsio('import Class, bind, log');var loggers={}\nvar levels=exports.levels={DEBUG:0,LOG:1,INFO:2,WARN:3,ERROR:4};var production=false;exports.setProduction=function(prod){production=!!prod;}\nexports.getLogger=function(name){if(!(name in loggers)){loggers[name]=new exports.Logger(name);}\nreturn loggers[name];}\nexports.Logger=Class(function(){this.init=function(name,level){if(!level){level=levels.LOG;}\nthis.name=name;this.level=level;}\nthis.setLevel=function(level){this.level=level;}\nfunction makeLogFunction(level,type){return function(){if(level<this.level||production)return;log.apply(log,[type,this.name].concat(Array.prototype.slice.call(arguments,0)));}}\nthis.debug=makeLogFunction(levels.DEBUG,\"DEBUG\");this.log=makeLogFunction(levels.LOG,\"LOG\");this.info=makeLogFunction(levels.INFO,\"INFO\");this.warn=makeLogFunction(levels.WARN,\"WARN\");this.error=makeLogFunction(levels.ERROR,\"ERROR\");})","location":"jsio/logging.js"},'jsio.protocols.buffered':{"src":"\njsio('import Class, bind, jsio.logging');jsio('from jsio.interfaces import Protocol');jsio('from jsio.buffer import Buffer');var logger=jsio.logging.getLogger('Buffered');exports.BufferedProtocol=Class(Protocol,function(supr){this.init=function(){this.buffer=new Buffer();}\nthis.bufferUpdated=function(){}\nthis.dataReceived=function(data){this.buffer.append(data);this.bufferUpdated();}})","location":"jsio/protocols/buffered.js"},'jsio.env':{"src":"\njsio('import log, bind');function getObj(objectName,transportName,envName){jsio('from .env.'+(envName||jsio.__env)+'.'+transportName+' import '+objectName+' as result');return result;}\nexports.getListener=bind(this,getObj,'Listener');exports.getConnector=bind(this,getObj,'Connector');","location":"jsio/env.js"},'jsio.csp.transports':{"src":"\njsio('import Class, bind');jsio('import jsio.std.uri as uri');jsio('import jsio.std.base64 as base64');jsio('import jsio.logging');jsio('import .errors');jsio('from jsio.util.browserdetect import BrowserDetect');var logger=jsio.logging.getLogger(\"csp.transports\");exports.allTransports={};exports.registerTransport=function(name,transport){logger.debug('registering transport',name);if(name in exports.allTransports){throw new Error(\"Transport \"+name+\" already exists\");}\nexports.allTransports[name]=transport;}\nvar isLocalFile=function(url,options){var test=location.toString().match('file://');if(test&&test.index===0){logger.debug('Detected Local file');return true;};return false;};var haveCrossDomain=function(url,options){try{if(window.XDomainRequest||window.XMLHttpRequest&&(new XMLHttpRequest()).withCredentials!==undefined){logger.debug('Detected xdomain xhr capabilities');return true;}}catch(e){}\nreturn false;};var isSameDomain=function(url,options){if(uri.isSameDomain(url,location.toString())){logger.debug('Detected same domain');return true;}\nreturn false;};var canChooseXHR=function(url,options){return(!isLocalFile(url,options)||(haveCrossDomain(url,options)||isSameDomain(url,options)));};var preferXHR=function(url,options){if(canChooseXHR(url,options)){return exports.allTransports.xhr;};return exports.allTransports.jsonp;};var preferJSONP=function(url,options){return exports.allTransports.jsonp;};exports.chooseTransport=function(url,options){if(options.preferredTransport=='xhr'){return preferXHR(url,options);}else if(options.preferredTransport=='jsonp'){return preferJSONP(url,options);}else{return exports.allTransports.jsonp;}\nlogger.debug('Detected cross-domain;'+' no xdomain xhr capabilities present;'+' choosing transport jsonp');return exports.allTransports.jsonp;};var PARAMS={'xhrstream':{\"is\":\"1\",\"bs\":\"\\n\"},'xhrpoll':{\"du\":\"0\"},'xhrlongpoll':{},'sselongpoll':{\"bp\":\"data: \",\"bs\":\"\\r\\n\",\"se\":\"1\"},'ssestream':{\"bp\":\"data: \",\"bs\":\"\\r\\n\",\"se\":\"1\",\"is\":\"1\"}};exports.Transport=Class(function(supr){this.handshake=function(url,options){throw new Error(\"handshake Not Implemented\");}\nthis.comet=function(url,sessionKey,lastEventId,options){throw new Error(\"comet Not Implemented\");}\nthis.send=function(url,sessionKey,data,options){throw new Error(\"send Not Implemented\");}\nthis.encodePacket=function(packetId,data,options){throw new Error(\"encodePacket Not Implemented\");}\nthis.abort=function(){throw new Error(\"abort Not Implemented\");}});var baseTransport=Class(exports.Transport,function(supr){this.init=function(){this._handshakeArgs={d:'{}',ct:'application/javascript'};}\nthis.handshake=function(url,options){logger.debug('handshake:',url,options);this._makeRequest('send',url+'/handshake',this._handshakeArgs,this.handshakeSuccess,this.handshakeFailure);}\nthis.comet=function(url,sessionKey,lastEventId,options){logger.debug('comet:',url,sessionKey,lastEventId,options);args={s:sessionKey,a:lastEventId}\nthis._makeRequest('comet',url+'/comet',args,this.cometSuccess,this.cometFailure);}\nthis.send=function(url,sessionKey,data,options){logger.debug('send:',url,sessionKey,data,options);args={d:data,s:sessionKey}\nthis._makeRequest('send',url+'/send',args,this.sendSuccess,this.sendFailure);}});exports.registerTransport('xhr',Class(baseTransport,function(supr){var createXHR=function(){return window.XMLHttpRequest?new XMLHttpRequest():window.XDomainRequest?new XDomainRequest():window.ActiveXObject?new ActiveXObject(\"Msxml2.XMLHTTP\"):null;}\nvar abortXHR=function(xhr){logger.debug('aborting XHR');try{if('onload'in xhr){xhr.onload=xhr.onerror=null;}else if('onreadystatechange'in xhr){xhr.onreadystatechange=null;}\nif(xhr.abort){xhr.abort();}}catch(e){logger.debug('error aborting xhr',e);}}\nthis.init=function(){supr(this,'init');this._xhr={'send':createXHR(),'comet':createXHR()};}\nthis.abort=function(){var xhr;for(var i in this._xhr){if(this._xhr.hasOwnProperty(i)){abortXHR(xhr);}}}\nthis.encodePacket=function(packetId,data,options){return data.indexOf('\\0')==-1?[packetId,0,data]:[packetId,1,base64.encode(data)];}\nthis._onReadyStateChange=function(rType,cb,eb){try{var xhr=this._xhr[rType];if(xhr.readyState!=4){return;}\nif(xhr.status!=200){logger.debug('XHR failed with status ',xhr.status);eb();}\nlogger.debug('XHR data received');cb(eval(xhr.responseText));}catch(e){var xhr=this._xhr[rType];logger.debug('Error in XHR::onReadyStateChange',e);eb();abortXHR(xhr);logger.debug('done handling XHR error');}}\nthis._makeRequest=function(rType,url,args,cb,eb){var xhr=this._xhr[rType],data=args.d||null;if('d'in args){delete args.d;}\nxhr.open('POST',url+'?'+uri.buildQuery(args));xhr.setRequestHeader('Content-Type','text/plain');if('onload'in xhr){xhr.onload=bind(this,'_onReadyStateChange',rType,cb,eb);xhr.onerror=xhr.ontimeout=eb;}else if('onreadystatechange'in xhr){xhr.onreadystatechange=bind(this,'_onReadyStateChange',rType,cb,eb);}\nif(data){xhr.send(data);}else{xhr.send();}}}));exports.registerTransport('jsonp',Class(baseTransport,function(supr){var logger=jsio.logging.getLogger('csp.transports.jsonp');var createIframe=function(){var i=document.createElement(\"iframe\");with(i.style){display='block';width=height=border=margin=padding='0';overflow=visibility='hidden';}\ni.cbId=0;i.src='javascript:document.open();document.write(\"<html><body></body></html>\")';document.body.appendChild(i);return i;}\nvar abortIframe=function(ifr){var win=ifr.contentWindow,doc=win.document;logger.debug('removing scripts');var scripts=doc.getElementsByTagName('script');var s1=doc.getElementsByTagName('script')[0];var s2=doc.getElementsByTagName('script')[1];if(s1)s1.parentNode.removeChild(s1);if(s2)s2.parentNode.removeChild(s2);logger.debug('removed scripts');logger.debug('deleting callbacks');win['cb'+(ifr.cbId-1)]=function(){};win['eb'+(ifr.cbId-1)]=function(){};}\nvar removeIframe=function(ifr){$setTimeout(function(){if(ifr&&ifr.parentNode){ifr.parentNode.removeChild(ifr);}},60000);}\nthis.init=function(){supr(this,'init');this._onReady=[];this._isReady=false;this._createIframes();}\nthis._createIframes=function(){if(!document.body){setTimeout(bind(this,'_createIframes'),100);return;}\nthis._isReady=true;this._ifr={'send':createIframe(),'comet':createIframe()};var readyArgs=this._onReady;this._onReady=[];for(var i=0,args;args=readyArgs[i];++i){this._makeRequest.apply(this,args);}}\nthis.encodePacket=function(packetId,data,options){return[packetId,1,base64.encode(data)];}\nthis.abort=function(){for(var i in this._ifr){if(this._ifr.hasOwnProperty(i)){var ifr=this._ifr[i];abortIframe(ifr);removeIframe(ifr);}}}\nthis._makeRequest=function(rType,url,args,cb,eb){if(!this._isReady){this._onReady.push(arguments);return;}\nargs.n=Math.random();$setTimeout(bind(this,function(){var ifr=this._ifr[rType];var win=ifr.contentWindow,doc=win.document,body=doc.body;var completed=false;var jsonpId=ifr.cbId++;var onFinish=win['eb'+jsonpId]=function(scriptTag){if(scriptTag&&scriptTag.readyState!='loaded'){return;}\nlogger.debug('in onFinish');if(!completed){logger.debug('error making request:',fullUrl);}\nabortIframe(ifr);if(!completed){logger.debug('calling eb');eb.apply(null,arguments);}}\nwin['cb'+jsonpId]=function callback(){logger.debug('successful: ',fullUrl,[].slice.call(arguments,0));completed=true;logger.debug('calling the cb');cb.apply(null,arguments);logger.debug('cb called');}\nswitch(rType){case'send':args.rs=';';args.rp='cb'+jsonpId;break;case'comet':args.bs=';';args.bp='cb'+jsonpId;break;}\nvar fullUrl=url+'?'+uri.buildQuery(args);if(BrowserDetect.isWebKit){doc.open();doc.write('<scr'+'ipt src=\"'+fullUrl+'\"></scr'+'ipt>');doc.write('<scr'+'ipt>eb'+jsonpId+'(false)</scr'+'ipt>');}else{var s=doc.createElement('script');s.src=fullUrl;if(s.onreadystatechange===null){s.onreadystatechange=bind(window,onFinish,s);}\nbody.appendChild(s);if(!BrowserDetect.isIE){var s=doc.createElement('script');s.innerHTML='eb'+jsonpId+'(false)';body.appendChild(s);}}\nkillLoadingBar();}),0);}\nfunction killLoadingBar(){}}));","location":"jsio/csp/transports.js"},'jsio.interfaces':{"src":"\njsio('import Class, bind');exports.Protocol=Class(function(){this.connectionMade=function(isReconnect){}\nthis.dataReceived=function(data){}\nthis.connectionLost=function(reason){}\nthis.connectionFailed=function(){}});exports.Server=Class(function(){this.init=function(protocolClass){this._protocolClass=protocolClass;}\nthis.buildProtocol=function(){return new this._protocolClass();}});exports.Transport=Class(function(){this.write=function(data,encoding){throw new Error(\"Not implemented\");}\nthis.getPeer=function(){throw new Error(\"Not implemented\");}});exports.Listener=Class(function(){this.init=function(server,opts){this._server=server;this._opts=opts||{};}\nthis.onConnect=function(transport){var p=this._server.buildProtocol();p.transport=transport;p.server=this._server;transport.protocol=p;transport.makeConnection(p);p.connectionMade();}\nthis.listen=function(){throw new Error('Abstract class');}\nthis.stop=function(){}});exports.Connector=Class(function(){this.init=function(protocol,opts){this._protocol=protocol;this._opts=opts;}\nthis.onConnect=function(transport){transport.makeConnection(this._protocol);this._protocol.transport=transport;this._protocol.connectionMade();}\nthis.getProtocol=function(){return this._protocol;}});exports.PubSub=Class(function(){this.publish=function(signal){if(!this._subscribers){return;}\nvar args=Array.prototype.slice.call(arguments,1);if(this._subscribers.__any){var anyArgs=[signal].concat(args);for(var i=0,sub;sub=this._subscribers.__any[i];++i){sub.apply(window,args);}}\nif(!this._subscribers[signal]){return;}\nfor(var i=0,sub;sub=this._subscribers[signal][i];++i){sub.apply(window,args);}}\nthis.subscribe=function(signal){if(!this._subscribers){this._subscribers={};}\nif(!this._subscribers[signal]){this._subscribers[signal]=[];}\nthis._subscribers[signal].push(bind.apply(jsio,Array.prototype.slice.call(arguments,1)));}});","location":"jsio/interfaces.js"},'jsio.csp.client':{"src":"\njsio('import jsio.std.base64 as base64');jsio('import jsio.std.utf8 as utf8');jsio('import jsio.std.uri as uri');jsio('import jsio.logging');jsio('import .errors');jsio('import .transports');var logger=jsio.logging.getLogger(\"csp.client\");var READYSTATE=exports.READYSTATE={INITIAL:0,CONNECTING:1,CONNECTED:2,DISCONNECTING:3,DISCONNECTED:4};exports.CometSession=Class(function(supr){var id=0;var kDefaultBackoff=50;var kDefaultTimeoutInterval=45000;var kDefaultHandshakeTimeout=10000;this.init=function(){this._id=++id;this._url=null;this.readyState=READYSTATE.INITIAL;this._sessionKey=null;this._transport=null;this._options=null;this._utf8ReadBuffer=\"\";this._writeBuffer=\"\";this._packetsInFlight=null;this._lastEventId=null;this._lastSentId=null;this._handshakeLater=null;this._handshakeBackoff=kDefaultBackoff;this._handshakeRetryTimer=null;this._handshakeTimeoutTimer=null;this._timeoutTimer=null;this._writeBackoff=kDefaultBackoff;this._writeRetryTimer=null;this.cometBackoff=kDefaultBackoff;this._cometRetryTimer=null;}\nthis.setEncoding=function(encoding){if(encoding==this._options.encoding){return;}\nif(encoding!='utf8'&&encoding!='plain'){throw new errors.InvalidEncodingError();}\nif(encoding=='plain'&&this._buffer){var buffer=this._utf8ReadBuffer;this._utf8ReadBuffer=\"\";this._doOnRead(buffer);}\nthis._options.encoding=encoding;}\nthis.connect=function(url,options){this._url=url;this._options=options||{};this._options.encoding=this._options.encoding||'utf8';this.setEncoding(this._options.encoding);this._options.connectTimeout=this._options.connectTimeout||kDefaultHandshakeTimeout;var transportClass=transports.chooseTransport(url,this._options);this._transport=new transportClass();this._transport.handshakeFailure=bind(this,this._handshakeFailure);this._transport.handshakeSuccess=bind(this,this._handshakeSuccess);this._transport.cometFailure=bind(this,this._cometFailure);this._transport.cometSuccess=bind(this,this._cometSuccess);this._transport.sendFailure=bind(this,this._writeFailure);this._transport.sendSuccess=bind(this,this._writeSuccess);this.readyState=READYSTATE.CONNECTING;this._transport.handshake(this._url,this._options);this._handshakeTimeoutTimer=$setTimeout(bind(this,this._handshakeTimeout),this._options.connectTimeout);}\nthis.write=function(data,encoding){if(this.readyState!=READYSTATE.CONNECTED){throw new errors.ReadyStateError();}\nencoding=encoding||this._options.encoding||'utf8';if(encoding=='utf8'){data=utf8.encode(data);}\nthis._writeBuffer+=data;this._doWrite();}\nthis.close=function(err){switch(this.readyState){case READYSTATE.CONNECTING:clearTimeout(this._handshakeRetryTimer);clearTimeout(this._handshakeTimeoutTimer);break;case READYSTATE.CONNECTED:this._transport.abort();clearTimeout(this._cometRetryTimer);clearTimeout(this._writeRetryTimer);clearTimeout(this._timeoutTimer);break;case READYSTATE.DISCONNECTED:throw new errors.ReadyStateError(\"Session is already disconnected\");break;}\nthis._doOnDisconnect(err);}\nthis._handshakeTimeout=function(){logger.debug('handshake timeout');this._handshakeTimeoutTimer=null;this._doOnDisconnect(new errors.HandshakeTimeout());}\nthis._handshakeSuccess=function(d){logger.debug('handshake success',d);if(this.readyState!=READYSTATE.CONNECTING){logger.debug('received handshake success in invalid readyState:',this.readyState);return;}\nclearTimeout(this._handshakeTimeoutTimer);this._handshakeTimeoutTimer=null;this._sessionKey=d.session;this._opened=true;this.readyState=READYSTATE.CONNECTED;this._doOnConnect();this._doConnectComet();}\nthis._handshakeFailure=function(e){logger.debug('handshake failure',e);if(this.readyState!=READYSTATE.CONNECTING){return;}\nlogger.debug('trying again in ',this._handshakeBackoff);this._handshakeRetryTimer=$setTimeout(bind(this,function(){this._handshakeRetryTimer=null;this._transport.handshake(this._url,this._options);}),this._handshakeBackoff);this._handshakeBackoff*=2;}\nthis._writeSuccess=function(){if(this.readyState!=READYSTATE.CONNECTED){return;}\nthis._resetTimeoutTimer();this.writeBackoff=kDefaultBackoff;this._packetsInFlight=null;if(this._writeBuffer){this._doWrite();}}\nthis._writeFailure=function(){if(this.readyState!=READYSTATE.CONNECTED){return;}\nthis._writeTimer=$setTimeout(bind(this,function(){this._writeTimer=null;this._doWrite();}),this._writeBackoff);this._writeBackoff*=2;}\nthis._doWrite=function(){if(this._packetsInFlight){return;}\nlogger.debug('_writeBuffer:',this._writeBuffer);this._packetsInFlight=[this._transport.encodePacket(++this._lastSentId,this._writeBuffer,this._options)];this._writeBuffer=\"\";logger.debug('sending packets:',JSON.stringify(this._packetsInFlight));this._transport.send(this._url,this._sessionKey,JSON.stringify(this._packetsInFlight),this._options);}\nthis._doConnectComet=function(){logger.debug('_doConnectComet');this._transport.comet(this._url,this._sessionKey,this._lastEventId||0,this._options);}\nthis._cometFailure=function(){if(this.readyState!=READYSTATE.CONNECTED){return;}\nthis._cometTimer=$setTimeout(bind(this,function(){this._doConnectComet();}),this._cometBackoff);this._cometBackoff*=2;}\nthis._cometSuccess=function(packets){if(this.readyState!=READYSTATE.CONNECTED){return;}\nlogger.debug('comet Success:',packets);this._cometBackoff=kDefaultBackoff;this._resetTimeoutTimer();for(var i=0,packet;(packet=packets[i])||i<packets.length;i++){logger.debug('process packet:',packet);if(packet===null){return self.close();}\nlogger.debug('process packet',packet);var ackId=packet[0];var encoding=packet[1];var data=packet[2];if(typeof(this._lastEventId)=='number'&&ackId<=this._lastEventId){continue;}\nif(typeof(this._lastEventId)=='number'&&ackId!=this._lastEventId+1){return this.close(new errors.ServerProtocolError(201));}\nthis._lastEventId=ackId;if(encoding==1){try{logger.debug('before base64 decode:',data);data=base64.decode(data);logger.debug('after base64 decode:',data);}catch(e){return this.close(new errors.ServerProtocolError(202));}}\nif(this._options.encoding=='utf8'){this._utf8ReadBuffer+=data;logger.debug('before utf8 decode, _utf8ReadBuffer:',this._utf8ReadBuffer);var result=utf8.decode(this._utf8ReadBuffer);data=result[0];this._utf8ReadBuffer=this._utf8ReadBuffer.slice(result[1]);logger.debug('after utf8 decode, _utf8ReadBuffer:',this._utf8ReadBuffer,'data:',data);}\nlogger.debug('dispatching data:',data);try{this._doOnRead(data);}catch(e){logger.error('application code threw an error. (re-throwing in timeout):',e);setTimeout(function(){logger.debug('timeout fired, throwing error',e);throw e;},0);}}\nthis._doConnectComet();}\nthis._doOnRead=function(data){if(typeof(this.onread)=='function'){logger.debug('call onread function',data);this.onread(data);}\nelse{logger.debug('skipping onread callback (function missing)');}}\nthis._doOnDisconnect=function(err){if(typeof(this.ondisconnect)=='function'){logger.debug('call ondisconnect function',err);this.ondisconnect(err);}\nelse{logger.debug('skipping ondisconnect callback (function missing)');}}\nthis._doOnConnect=function(){if(typeof(this.onconnect)=='function'){logger.debug('call onconnect function');try{this.onconnect();}catch(e){logger.debug('onconnect caused errror',e);setTimeout(function(){throw e},0);}}\nelse{logger.debug('skipping onconnect callback (function missing)');}}\nthis._resetTimeoutTimer=function(){clearTimeout(this._timeoutTimer);this._timeoutTimer=$setTimeout(bind(this,function(){logger.debug('connection timeout expired');this.close(new errors.SessionTimeout())}),this._getTimeoutInterval())}\nthis._getTimeoutInterval=function(){return kDefaultTimeoutInterval;}});","location":"jsio/csp/client.js"},'jsio.protocols.mspp':{"src":"\njsio('import Class, log, jsio.logging');jsio('import jsio.std.utf8 as utf8');jsio('from jsio.protocols.buffered import BufferedProtocol');var loggers={};loggers.stream=jsio.logging.getLogger('MSPPStream');loggers.protocol=jsio.logging.getLogger('MSPPProtocol');loggers.stream.setLevel(0);loggers.protocol.setLevel(0);var frames={'OPEN':0,'CLOSE':1,'DATA':2};exports.MSPPStream=Class(function(){this.setMultiplexer=function(multiplexer){loggers.stream.debug('setMultiplexer: '+multiplexer);this.multiplexer=multiplexer;}\nthis.setEncoding=function(encoding){loggers.stream.debug('setEncoding: '+encoding);this.encoding=encoding;}\nthis.open=function(host,port,isBinary){if(isBinary)\nthis.encoding='utf8';this.id=this.multiplexer.openStream(this,host,port);loggers.stream.debug('open '+this.id+\": \"+host+\" \"+port+\" \"+isBinary);}\nthis.close=function(){loggers.stream.debug('close '+this.id);this.multiplexer.close(this.id);}\nthis.send=function(data,encoding){loggers.stream.debug('send '+this.id+\": \"+data+\" \"+encoding);if((encoding||this.encoding)=='utf8')\ndata=utf8.encode(data);this.multiplexer.writeToStream(this.id,data);}\nthis._onreadraw=function(data){if(this.encoding=='utf8')\ndata=utf8.decode(data);loggers.stream.debug('_onreadraw '+data);this.onread(data);}\nthis.onopen=function(){}\nthis.onclose=function(err){}\nthis.onread=function(data){}});var state={};state.closed=0;state.connecting=1;state.consuming=2;exports.MSPPProtocol=Class(BufferedProtocol,function(supr){this.init=function(){loggers.protocol.debug('new MSPPProtocol');supr(this,'init',[]);this.state=state.closed;this.transportType=null;this.transportOptions=null;this.currentId=0;this.streams={};this.writeBuffer=[];}\nthis.setTransport=function(transportType,transportOptions){this.transportType=transportType;this.transportOptions=transportOptions;}\nthis.connectionMade=function(isReconnect){loggers.protocol.debug('connectionMade');this.state=state.consuming;for(var i=0;i<this.writeBuffer.length;i++)\nthis._write(this.writeBuffer[i]);writeBuffer=[];}\nthis.connectionLost=this.connectionFailed=function(reason){loggers.protocol.debug('closed: '+reason);this.state=state.closed;for(stream in this.streams)\nthis.streams[stream].onclose(reason);}\nthis.openStream=function(stream,host,port){if(this.state==state.closed){this.state=state.connecting;jsio.connect(this,this.transportType,this.transportOptions);}\nvar id=++this.currentId;this.streams[id]=stream;this._write([id,frames.OPEN,host+\",\"+port]);return id;}\nthis.closeStream=function(id){this._write([id,frames.CLOSE,\"\"]);}\nthis.writeToStream=function(id,data){this._write([id,frames.DATA,data]);}\nthis.bufferUpdated=function(){loggers.protocol.debug(\"bufferUpdated. state: \"+this.state+\". buffer: \"+this.buffer._rawBuffer);if(this.state!=state.consuming)\nthrow new Error(\"buffer update in invalid MSPP state: \"+this.state);if(!this.buffer.hasDelimiter(':'))\nreturn;var lStr=this.buffer.peekToDelimiter(':');var len=parseInt(lStr);if(!this.buffer.hasBytes(len+lStr.length+1))\nreturn;this.buffer.consumeThroughDelimiter(':');var streamId=this.buffer.consumeToDelimiter(',');this.buffer.consumeBytes(1);var frameType=parseInt(this.buffer.consumeBytes(1));len-=(streamId.length+2);streamId=parseInt(streamId);var data=this.buffer.consumeBytes(len);switch(frameType){case frames.OPEN:this.streams[streamId].onopen();break;case frames.CLOSE:this.streams[streamId].onclose(data);break;case frames.DATA:this.streams[streamId]._onreadraw(data);break;default:throw new Error('invalid MSPP data type!');}}\nthis._write=function(data){if(this.state!=state.consuming){loggers.protocol.debug(\"buffering write: \"+data);this.writeBuffer.push(data);return;}\nvar s=data[0]+\",\"+data[1]+data[2];s=s.length+\":\"+s;loggers.protocol.debug('write: '+s);this.transport.write(s);}});","location":"jsio/protocols/mspp.js"},'jsio.csp.errors':{"src":"\nvar makeErrorClass=function(name,_code){var out=function(message,code){this.message=message;this.code=code||_code;}\nout.prototype.toString=function(){return name+(this.message?': '+this.message:'');}\nreturn out;}\nexports.ReadyStateError=makeErrorClass(\"ReadyStateError\");exports.InvalidEncodingError=makeErrorClass(\"InvalidEncodingError\");exports.HandshakeTimeout=makeErrorClass(\"HandshakeTimeout\",100);exports.SessionTimeout=makeErrorClass(\"HandshakeTimeout\",101);exports.ServerProtocolError=makeErrorClass(\"ServerProtocolError\",200);","location":"jsio/csp/errors.js"},'Orbited':{"src":"\njsio('import Class');jsio('import jsio.logging');jsio('from jsio.protocols.mspp import MSPPStream, MSPPProtocol');exports.logging=jsio.logging;exports.settings={'host':'localhost','port':8000,'path':'/csp'};var multiplexer=null;exports.TCPSocket=Class(MSPPStream,function(){this.init=function(){this.setEncoding('plain');if(multiplexer==null){multiplexer=new MSPPProtocol();multiplexer.setTransport('csp',{\"url\":\"http://\"+exports.settings.host+\":\"+exports.settings.port+exports.settings.path});}\nthis.setMultiplexer(multiplexer);}});","location":"Orbited.js"},'jsio.std.JSON':{"src":"\nexports.createGlobal=function(){if(typeof JSON=='undefined'){JSON={};}\nif(typeof JSON.stringify!=='function'){JSON.stringify=exports.stringify;}\nif(typeof JSON.parse!=='function'){JSON.parse=exports.parse;}};;(function(){var cx=/[\\u0000\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,escapable=/[\\\\\\\"\\x00-\\x1f\\x7f-\\x9f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]/g,gap,indent,meta={'\\b':'\\\\b','\\t':'\\\\t','\\n':'\\\\n','\\f':'\\\\f','\\r':'\\\\r','\"':'\\\\\"','\\\\':'\\\\\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'\"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'\"':'\"'+string+'\"';}\nfunction str(key,holder){var mind=gap,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}\nif(typeof rep==='function'){value=rep.call(holder,key,value);}\nswitch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':return String(value);case'object':if(value===null){return'null';}\nif(value.constructor===Date){return exports.stringifyDate(value);}\ngap+=indent;var partial=[];if(value.constructor===Array){var length=value.length;for(var i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}\nvar v=partial.length===0?'[]':gap?'[\\n'+gap+\npartial.join(',\\n'+gap)+'\\n'+\nmind+']':'['+partial.join(',')+']';gap=mind;return v;}\nif(rep&&typeof rep==='object'){var length=rep.length;for(var i=0;i<length;i+=1){var k=rep[i];if(typeof k==='string'){var v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(var k in value){if(Object.hasOwnProperty.call(value,k)){var v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}\nvar v=partial.length===0?'{}':gap?'{\\n'+gap+partial.join(',\\n'+gap)+'\\n'+\nmind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}\nexports.stringify=function(value,replacer,space){gap='';indent='';if(typeof space==='number'){for(var i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}\nrep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON stringify: invalid replacer');}\nreturn str('',{'':value});};exports.stringifyDate=function(d){var year=d.getUTCFullYear(),month=d.getUTCMonth()+1,day=d.getUTCDate(),hours=d.getUTCHours(),minutes=d.getUTCMinutes(),seconds=d.getUTCSeconds(),ms=d.getUTCMilliseconds();if(month<10){month='0'+month;}\nif(day<10){day='0'+day;}\nif(hours<10){hours='0'+hours;}\nif(minutes<10){minutes='0'+minutes;}\nif(seconds<10){seconds='0'+seconds;}\nif(ms<10){ms='00'+ms;}\nelse if(ms<100){ms='0'+ms;}\nreturn'\"'+year\n+'-'+month\n+'-'+day\n+'T'+hours\n+':'+minutes\n+':'+seconds\n+'.'+ms\n+'Z\"';}\nexports.parse=function(text,reviver){cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\\\u'+\n('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}\nif(/^[\\],:{}\\s]*$/.test(text.replace(/\\\\(?:[\"\\\\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/\"[^\"\\\\\\n\\r]*\"|true|false|null|-?\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d+)?/g,']').replace(/(?:^|:|,)(?:\\s*\\[)+/g,'')))\n{var j=eval('('+text+')');if(!reviver){return j;}else{var walk=function(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}\nreturn reviver.call(holder,key,value);}\nreturn walk({'':j},'');}}\nthrow new SyntaxError('JSON.parse');};}());","location":"jsio/std/JSON.js"},'jsio.env.browser.csp':{"src":"\njsio('import Class, bind, jsio.logging, jsio.interfaces');jsio('from jsio.csp.client import CometSession');var logger=jsio.logging.getLogger('env.browser.csp');exports.Connector=Class(jsio.interfaces.Connector,function(){this.connect=function(){var conn=new CometSession();conn.onconnect=bind(this,function(){logger.debug('conn has opened');this.onConnect(new Transport(conn));});conn.ondisconnect=bind(this,function(code){logger.debug('conn closed without opening, code:',code);});logger.debug('open the conection');this._opts.encoding='plain';var url=this._opts.url;delete this._opts.url;conn.connect(url,this._opts);}});var Transport=Class(jsio.interfaces.Transport,function(){this.init=function(conn){this._conn=conn;}\nthis.makeConnection=function(protocol){this._conn.onread=bind(protocol,'dataReceived');this._conn.ondisconnect=bind(protocol,'connectionLost');}\nthis.write=function(data,encoding){this._conn.write(data);}\nthis.loseConnection=function(protocol){this._conn.close();}});","location":"jsio/env/browser/csp.js"},'jsio.std.utf8':{"src":"\nexports.UnicodeCodecError=function(message){this.message=message;};var UnicodeCodecError=exports.UnicodeCodecError;UnicodeCodecError.prototype.toString=function(){return'UnicodeCodecError'+(this.message?': '+this.message:'');};exports.encode=function(unicode_string){try{return unescape(encodeURIComponent(unicode_string));}\ncatch(err){throw new UnicodeCodecError('invalid input string');};};exports.decode=function(bytes){if(/[^\\x00-\\xFF]/.test(bytes)){throw new UnicodeCodecError('invalid utf-8 bytes');};var len,len_parsed;len=len_parsed=bytes.length;var last=len-1;if(bytes.charCodeAt(last)>=0x80){for(var i=1;i<=3;i++){if(bytes.charCodeAt(len-i)>=0xC0){len_parsed=len-i;break;};};try{decodeURIComponent(escape(bytes.slice(len_parsed)));len_parsed=len;}\ncatch(err){};};try{return[decodeURIComponent(escape(bytes.slice(0,len_parsed))),len_parsed];}\ncatch(err){throw new UnicodeCodecError('invalid utf-8 bytes');};};","location":"jsio/std/utf8.js"},'jsio.util.browserdetect':{"src":"\nexports.BrowserDetect=new function(){var versionSearchString;var dataBrowser=[{string:navigator.userAgent,subString:\"Chrome\"},{string:navigator.userAgent,subString:\"OmniWeb\",versionSearch:\"OmniWeb/\"},{string:navigator.vendor,subString:\"Apple\",identity:\"Safari\",versionSearch:\"Version\"},{prop:window.opera,identity:\"Opera\"},{string:navigator.vendor,subString:\"iCab\"},{string:navigator.vendor,subString:\"KDE\",identity:\"Konqueror\"},{string:navigator.userAgent,subString:\"Firefox\"},{string:navigator.vendor,subString:\"Camino\"},{string:navigator.userAgent,subString:\"Netscape\"},{string:navigator.userAgent,subString:\"MSIE\",identity:\"IE\",versionSearch:\"MSIE\"},{string:navigator.userAgent,subString:\"Gecko\",identity:\"Mozilla\",versionSearch:\"rv\"},{string:navigator.userAgent,subString:\"Mozilla\",identity:\"Netscape\",versionSearch:\"Mozilla\"}];var dataOS=[{string:navigator.platform,subString:\"Win\",identity:\"Windows\"},{string:navigator.platform,subString:\"Mac\"},{string:navigator.userAgent,subString:\"iPhone\",identity:\"iPhone/iPod\"},{string:navigator.platform,subString:\"Linux\"}];function searchString(data){for(var i=0,item;item=data[i];i++){var dataString=item.string;var dataProp=item.prop;item.identity=item.identity||item.subString;versionSearchString=item.versionSearch||item.identity;if(dataString){if(dataString.indexOf(item.subString)!=-1)\nreturn item.identity;}else if(dataProp)\nreturn item.identity;}}\nfunction searchVersion(dataString){var index=dataString.indexOf(versionSearchString);if(index==-1)return;return parseFloat(dataString.substring(index+versionSearchString.length+1));}\nthis.browser=searchString(dataBrowser)||\"unknown\";this.version=searchVersion(navigator.userAgent)||searchVersion(navigator.appVersion)||\"unknown\";this.OS=searchString(dataOS)||\"unknown\";this.isWebKit=RegExp(\" AppleWebKit/\").test(navigator.userAgent);this['is'+this.browser]=this.version;};","location":"jsio/util/browserdetect.js"}};var pre_jsioImport=[];if(typeof exports=='undefined'){var jsio=window.jsio=bind(this,_jsioImport,window,'')}else if(typeof GLOBAL!='undefined'){var jsio=bind(this,_jsioImport,GLOBAL,'');}
 jsio.script_src='Orbited.js';var modulePathCache={}
 function getModulePathPossibilities(pathString){var segments=pathString.split('.')
 var modPath=segments.join('/');var out;if(segments[0]in modulePathCache){out=[[modulePathCache[segments[0]]+'/'+modPath+'.js',null]];}else{out=[];for(var i=0,path;path=jsio.path[i];++i){out.push([path+'/'+modPath+'.js',path]);}}
 if(typeof eval('(function(){})')=='undefined'){RUNTIME.eval=function(src){try{eval('jsio.__f='+src);return jsio.__f;}finally{delete jsio.__f;}}}
 modulePathCache.jsio=cwd;break;}
 function browser_findScript(){try{var scripts=document.getElementsByTagName('script');for(var i=0,script;script=scripts[i];++i){if((script.src==jsio.script_src)||(script.src.slice(script.src.length-jsio.script_src.length)==jsio.script_src)){return makeAbsoluteURL(script.src,window.location);}}}catch(e){}}
-function browser_getLog(){if(typeof console!='undefined'&&console.log){return console.log;}else{return browser_oldLog;}}
+function browser_getLog(){if(typeof console!='undefined'&&console.log){return bind(console,'log');}else{return browser_oldLog;}}
 function browser_oldLog(){var d=document.createElement('div');document.body.appendChild(d);out=[]
 for(var i=0,item;(item=arguments[i])||i<arguments.length;++i){try{out.push(JSON.stringify(item));}catch(e){out.push(item.toString());}}
 d.innerHTML=out.join(", ");}
 var cwd=RUNTIME.cwd();var makeRelative=function(path){var i=path.match('^'+cwd);if(i&&i[0]==cwd){var offset=path[cwd.length]=='/'?1:0
 return path.slice(cwd.length+offset);}
 return path;}
-var getModuleSourceAndPath=function(pathString){var baseMod=pathString.split('.')[0];var paths=getModulePathPossibilities(pathString);var cwd=RUNTIME.cwd()+'/';for(var i=0,path;path=paths[i];++i){var cachePath=path[1];var path=path[0];try{var out={src:RUNTIME.readFile(path).wait(),location:path};if(!(baseMod in modulePathCache)){modulePathCache[baseMod]=cachePath;}
+var getModuleSourceAndPath=function(pathString){if(preloaded_source[pathString]){return preloaded_source[pathString];}
+var baseMod=pathString.split('.')[0];var paths=getModulePathPossibilities(pathString);var cwd=RUNTIME.cwd()+'/';for(var i=0,path;path=paths[i];++i){var cachePath=path[1];var path=path[0];try{var out={src:RUNTIME.readFile(path).wait(),location:path};if(!(baseMod in modulePathCache)){modulePathCache[baseMod]=cachePath;}
 return out;}catch(e){}}
 throw new Error("Module not found: "+pathString+"\n(looked in "+paths+")");}
 var segments=__filename.split('/');var jsioPath=segments.slice(0,segments.length-2).join('/');if(jsioPath){jsio.path.push(jsioPath);modulePathCache.jsio=jsioPath;}else{modulePathCache.jsio='.';}
 var _localContext={};var _jsio=_localContext.jsio=bind(this,_jsioImport,_localContext,'jsio');_jsio('import jsio.env');_jsio('import jsio.std.JSON');_jsio.std.JSON.createGlobal();jsio.listen=function(server,transportName,opts){var listenerClass=_jsio.env.getListener(transportName);var listener=new listenerClass(server,opts);listener.listen();return listener;}
 jsio.connect=function(protocolInstance,transportName,opts){var connector=new(_jsio.env.getConnector(transportName))(protocolInstance,opts);connector.connect();return connector;}
 jsio.quickServer=function(protocolClass){_jsio('import .interfaces');return new _jsio.interfaces.Server(protocolClass);}
-for(var i=0,target;target=pre_jsioImport[i];++i){jsio.require(target);}})();jsio("import Orbited");delete jsio;
+for(var i=0,target;target=pre_jsioImport[i];++i){jsio.require(target);}
+jsio("import Orbited");})();