Commits

Anonymous committed e81af75

Checkpoint commit

Comments (0)

Files changed (21)

+node_modules
+.monitor
+.DS_Store
+.idea
+support
+test
+examples
+*.sock
+
+0.0.1 / 2010-01-03
+==================
+
+  * Initial release
+
+test:
+	@./node_modules/.bin/mocha \
+		--require should \
+		--reporter spec
+
+.PHONY: test
+
+# lib-faye
+
+  Faye Service Library Plugin for the DreamFactory Services Platform(tm)
+
+## License 
+
+(The MIT License)
+
+Copyright (c) 2012 Jerry Ablan <jerryablan@dreamfactory.com>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+<!DOCTYPE html>
+<html>
+<head>
+	<title>Faye Service Library for DSPs</title>
+	<script data-main="scripts/main" src="scripts/require.js"></script>
+</head>
+<body>
+	<h1>jQuery+RequireJS Sample Page</h1>
+
+	<p>Look at source or inspect the DOM to see how it works.</p>
+</body>
+</html>
+node_modules
+.monitor
+.DS_Store
+.idea
+support
+test
+examples
+*.sock
+
+0.0.1 / 2010-01-03
+==================
+
+  * Initial release
+
+test:
+	@./node_modules/.bin/mocha \
+		--require should \
+		--reporter spec
+
+.PHONY: test
+
+# lib-faye
+
+  Faye Service Library Plugin for the DreamFactory Services Platform(tm)
+
+## License 
+
+(The MIT License)
+
+Copyright (c) 2012 Jerry Ablan &lt;jerryablan@dreamfactory.com&gt;
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+<!DOCTYPE html>
+<html>
+<head>
+	<title>Faye Service Library for DSPs</title>
+	<script data-main="scripts/main" src="scripts/require.js"></script>
+</head>
+<body>
+	<h1>jQuery+RequireJS Sample Page</h1>
+
+	<p>Look at source or inspect the DOM to see how it works.</p>
+</body>
+</html>
+
+scripts/main.js
+----------------
+../node_modules/faye/browser/faye-browser-min.js
+scripts/main.js
+module.exports=require("./scripts/main.js");

build/package.json

+{
+    "name"          : "lib-faye",
+    "description"   : "Faye service library for the DreamFactory Services Platform(tm)",
+    "version"       : "1.0.0",
+    "homepage"      : "http://github.com/dreamfactorysoftware/lib-faye",
+    "author"        : {
+        "name" : "Jerry Ablan",
+        "email": "jerryablan@dreamfactory.com"
+    },
+    "licenses"      : [
+        {
+            "type": "GPL3",
+            "url" : "https://github.com/dreamfactorysoftware/lib-faye/blob/master/LICENSE"
+        }
+    ],
+    "main"          : "index",
+    "engines"       : {
+        "node": ">=0.10.0"
+    },
+    "readmeFilename": "README.md"
+}

build/scripts/build.js

+({appDir:"../",baseUrl:"scripts",dir:"../build",optimize:"uglify",optimizeCss:"standard",paths:{},modules:[{name:"main"}]});

build/scripts/main.js

+/*!
+     * FayeService
+     * An ultra-thin wrapper around the faye.js client
+     *
+     * @author Jerry Ablan <jerryablan@dreamfactory.com>
+     */
+
+var Faye={VERSION:"0.8.9",BAYEUX_VERSION:"1.0",ID_LENGTH:160,JSONP_CALLBACK:"jsonpcallback",CONNECTION_TYPES:["long-polling","cross-origin-long-polling","callback-polling","websocket","eventsource","in-process"],MANDATORY_CONNECTION_TYPES:["long-polling","callback-polling","in-process"],ENV:typeof global=="undefined"?window:global,extend:function(e,t,n){if(!t)return e;for(var r in t){if(!t.hasOwnProperty(r))continue;if(e.hasOwnProperty(r)&&n===!1)continue;e[r]!==t[r]&&(e[r]=t[r])}return e},random:function(e){e=e||this.ID_LENGTH;if(e>32){var t=Math.ceil(e/32),n="";while(t--)n+=this.random(32);var r=n.split(""),i="";while(r.length>0)i+=r.pop();return i}var s=Math.pow(2,e)-1,o=s.toString(36).length,n=Math.floor(Math.random()*s).toString(36);while(n.length<o)n="0"+n;return n},clientIdFromMessages:function(e){var t=[].concat(e)[0];return t&&t.clientId},copyObject:function(e){var t,n,r;if(e instanceof Array){t=[],n=e.length;while(n--)t[n]=Faye.copyObject(e[n]);return t}if(typeof e=="object"){t=e===null?null:{};for(r in e)t[r]=Faye.copyObject(e[r]);return t}return e},commonElement:function(e,t){for(var n=0,r=e.length;n<r;n++)if(this.indexOf(t,e[n])!==-1)return e[n];return null},indexOf:function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},map:function(e,t,n){if(e.map)return e.map(t,n);var r=[];if(e instanceof Array)for(var i=0,s=e.length;i<s;i++)r.push(t.call(n||null,e[i],i));else for(var o in e){if(!e.hasOwnProperty(o))continue;r.push(t.call(n||null,o,e[o]))}return r},filter:function(e,t,n){var r=[];for(var i=0,s=e.length;i<s;i++)t.call(n||null,e[i],i)&&r.push(e[i]);return r},asyncEach:function(e,t,n,r){var i=e.length,s=-1,o=0,u=!1,a=function(){o-=1,s+=1;if(s===i)return n&&n.call(r);t(e[s],l)},f=function(){if(u)return;u=!0;while(o>0)a();u=!1},l=function(){o+=1,f()};l()},toJSON:function(e){return this.stringify?this.stringify(e,function(e,t){return this[e]instanceof Array?this[e]:t}):JSON.stringify(e)},logger:function(e){typeof console!="undefined"&&console.log(e)},timestamp:function(){var e=new Date,t=e.getFullYear(),n=e.getMonth()+1,r=e.getDate(),i=e.getHours(),s=e.getMinutes(),o=e.getSeconds(),u=function(e){return e<10?"0"+e:String(e)};return u(t)+"-"+u(n)+"-"+u(r)+" "+u(i)+":"+u(s)+":"+u(o)}};typeof window!="undefined"&&(window.Faye=Faye),Faye.Class=function(e,t){typeof e!="function"&&(t=e,e=Object);var n=function(){return this.initialize?this.initialize.apply(this,arguments)||this:this},r=function(){};return r.prototype=e.prototype,n.prototype=new r,Faye.extend(n.prototype,t),n},Faye.Namespace=Faye.Class({initialize:function(){this._e={}},exists:function(e){return this._e.hasOwnProperty(e)},generate:function(){var e=Faye.random();while(this._e.hasOwnProperty(e))e=Faye.random();return this._e[e]=e},release:function(e){delete this._e[e]}}),Faye.Error=Faye.Class({initialize:function(e,t,n){this.code=e,this.params=Array.prototype.slice.call(t),this.message=n},toString:function(){return this.code+":"+this.params.join(",")+":"+this.message}}),Faye.Error.parse=function(e){e=e||"";if(!Faye.Grammar.ERROR.test(e))return new this(null,[],e);var t=e.split(":"),n=parseInt(t[0]),r=t[1].split(","),e=t[2];return new this(n,r,e)},Faye.Error.versionMismatch=function(){return(new this(300,arguments,"Version mismatch")).toString()},Faye.Error.conntypeMismatch=function(){return(new this(301,arguments,"Connection types not supported")).toString()},Faye.Error.extMismatch=function(){return(new this(302,arguments,"Extension mismatch")).toString()},Faye.Error.badRequest=function(){return(new this(400,arguments,"Bad request")).toString()},Faye.Error.clientUnknown=function(){return(new this(401,arguments,"Unknown client")).toString()},Faye.Error.parameterMissing=function(){return(new this(402,arguments,"Missing required parameter")).toString()},Faye.Error.channelForbidden=function(){return(new this(403,arguments,"Forbidden channel")).toString()},Faye.Error.channelUnknown=function(){return(new this(404,arguments,"Unknown channel")).toString()},Faye.Error.channelInvalid=function(){return(new this(405,arguments,"Invalid channel")).toString()},Faye.Error.extUnknown=function(){return(new this(406,arguments,"Unknown extension")).toString()},Faye.Error.publishFailed=function(){return(new this(407,arguments,"Failed to publish")).toString()},Faye.Error.serverError=function(){return(new this(500,arguments,"Internal server error")).toString()},Faye.Deferrable={callback:function(e,t){if(!e)return;if(this._v==="succeeded")return e.apply(t,this._j);this._k=this._k||[],this._k.push([e,t])},timeout:function(e,t){var n=this,r=Faye.ENV.setTimeout(function(){n.setDeferredStatus("failed",t)},e*1e3);this._w=r},errback:function(e,t){if(!e)return;if(this._v==="failed")return e.apply(t,this._j);this._l=this._l||[],this._l.push([e,t])},setDeferredStatus:function(){this._w&&Faye.ENV.clearTimeout(this._w);var e=Array.prototype.slice.call(arguments),t=e.shift(),n;this._v=t,this._j=e,t==="succeeded"?n=this._k:t==="failed"&&(n=this._l);if(!n)return;var r;while(r=n.shift())r[0].apply(r[1],this._j)}},Faye.Publisher={countListeners:function(e){return!this._4||!this._4[e]?0:this._4[e].length},bind:function(e,t,n){this._4=this._4||{};var r=this._4[e]=this._4[e]||[];r.push([t,n])},unbind:function(e,t,n){if(!this._4||!this._4[e])return;if(!t){delete this._4[e];return}var r=this._4[e],i=r.length;while(i--){if(t!==r[i][0])continue;if(n&&r[i][1]!==n)continue;r.splice(i,1)}},trigger:function(){var e=Array.prototype.slice.call(arguments),t=e.shift();if(!this._4||!this._4[t])return;var n=this._4[t].slice(),r;for(var i=0,s=n.length;i<s;i++)r=n[i],r[0].apply(r[1],e)}},Faye.Timeouts={addTimeout:function(e,t,n,r){this._6=this._6||{};if(this._6.hasOwnProperty(e))return;var i=this;this._6[e]=Faye.ENV.setTimeout(function(){delete i._6[e],n.call(r)},1e3*t)},removeTimeout:function(e){this._6=this._6||{};var t=this._6[e];if(!t)return;clearTimeout(t),delete this._6[e]}},Faye.Logging={LOG_LEVELS:{error:3,warn:2,info:1,debug:0},logLevel:"error",log:function(e,t){if(!Faye.logger)return;var n=Faye.Logging.LOG_LEVELS;if(n[Faye.Logging.logLevel]>n[t])return;var e=Array.prototype.slice.apply(e),r=" ["+t.toUpperCase()+"] [Faye",i=this.className,s=e.shift().replace(/\?/g,function(){try{return Faye.toJSON(e.shift())}catch(t){return"[Object]"}});for(var o in Faye){if(i)continue;if(typeof Faye[o]!="function")continue;this instanceof Faye[o]&&(i=o)}i&&(r+="."+i),r+="] ",Faye.logger(Faye.timestamp()+r+s)}},function(){for(var e in Faye.Logging.LOG_LEVELS)(function(e,t){Faye.Logging[e]=function(){this.log(arguments,e)}})(e,Faye.Logging.LOG_LEVELS[e])}(),Faye.Grammar={LOWALPHA:/^[a-z]$/,UPALPHA:/^[A-Z]$/,ALPHA:/^([a-z]|[A-Z])$/,DIGIT:/^[0-9]$/,ALPHANUM:/^(([a-z]|[A-Z])|[0-9])$/,MARK:/^(\-|\_|\!|\~|\(|\)|\$|\@)$/,STRING:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,TOKEN:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,INTEGER:/^([0-9])+$/,CHANNEL_SEGMENT:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+$/,CHANNEL_SEGMENTS:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,CHANNEL_NAME:/^\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*$/,WILD_CARD:/^\*{1,2}$/,CHANNEL_PATTERN:/^(\/(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)))+)*\/\*{1,2}$/,VERSION_ELEMENT:/^(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*$/,VERSION:/^([0-9])+(\.(([a-z]|[A-Z])|[0-9])(((([a-z]|[A-Z])|[0-9])|\-|\_))*)*$/,CLIENT_ID:/^((([a-z]|[A-Z])|[0-9]))+$/,ID:/^((([a-z]|[A-Z])|[0-9]))+$/,ERROR_MESSAGE:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*$/,ERROR_ARGS:/^(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*$/,ERROR_CODE:/^[0-9][0-9][0-9]$/,ERROR:/^([0-9][0-9][0-9]:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*(,(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)*:(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*|[0-9][0-9][0-9]::(((([a-z]|[A-Z])|[0-9])|(\-|\_|\!|\~|\(|\)|\$|\@)| |\/|\*|\.))*)$/},Faye.Extensible={addExtension:function(e){this._7=this._7||[],this._7.push(e),e.added&&e.added(this)},removeExtension:function(e){if(!this._7)return;var t=this._7.length;while(t--){if(this._7[t]!==e)continue;this._7.splice(t,1),e.removed&&e.removed(this)}},pipeThroughExtensions:function(e,t,n,r){this.debug("Passing through ? extensions: ?",e,t);if(!this._7)return n.call(r,t);var i=this._7.slice(),s=function(t){if(!t)return n.call(r,t);var o=i.shift();if(!o)return n.call(r,t);o[e]?o[e](t,s):s(t)};s(t)}},Faye.extend(Faye.Extensible,Faye.Logging),Faye.Channel=Faye.Class({initialize:function(e){this.id=this.name=e},push:function(e){this.trigger("message",e)},isUnused:function(){return this.countListeners("message")===0}}),Faye.extend(Faye.Channel.prototype,Faye.Publisher),Faye.extend(Faye.Channel,{HANDSHAKE:"/meta/handshake",CONNECT:"/meta/connect",SUBSCRIBE:"/meta/subscribe",UNSUBSCRIBE:"/meta/unsubscribe",DISCONNECT:"/meta/disconnect",META:"meta",SERVICE:"service",expand:function(e){var t=this.parse(e),n=["/**",e],r=t.slice();r[r.length-1]="*",n.push(this.unparse(r));for(var i=1,s=t.length;i<s;i++)r=t.slice(0,i),r.push("**"),n.push(this.unparse(r));return n},isValid:function(e){return Faye.Grammar.CHANNEL_NAME.test(e)||Faye.Grammar.CHANNEL_PATTERN.test(e)},parse:function(e){return this.isValid(e)?e.split("/").slice(1):null},unparse:function(e){return"/"+e.join("/")},isMeta:function(e){var t=this.parse(e);return t?t[0]===this.META:null},isService:function(e){var t=this.parse(e);return t?t[0]===this.SERVICE:null},isSubscribable:function(e){return this.isValid(e)?!this.isMeta(e)&&!this.isService(e):null},Set:Faye.Class({initialize:function(){this._2={}},getKeys:function(){var e=[];for(var t in this._2)e.push(t);return e},remove:function(e){delete this._2[e]},hasSubscription:function(e){return this._2.hasOwnProperty(e)},subscribe:function(e,t,n){if(!t)return;var r;for(var i=0,s=e.length;i<s;i++){r=e[i];var o=this._2[r]=this._2[r]||new Faye.Channel(r);o.bind("message",t,n)}},unsubscribe:function(e,t,n){var r=this._2[e];return r?(r.unbind("message",t,n),r.isUnused()?(this.remove(e),!0):!1):!1},distributeMessage:function(e){var t=Faye.Channel.expand(e.channel);for(var n=0,r=t.length;n<r;n++){var i=this._2[t[n]];i&&i.trigger("message",e.data)}}})}),Faye.Publication=Faye.Class(Faye.Deferrable),Faye.Subscription=Faye.Class({initialize:function(e,t,n,r){this._8=e,this._2=t,this._m=n,this._n=r,this._x=!1},cancel:function(){if(this._x)return;this._8.unsubscribe(this._2,this._m,this._n),this._x=!0},unsubscribe:function(){this.cancel()}}),Faye.extend(Faye.Subscription.prototype,Faye.Deferrable),Faye.Client=Faye.Class({UNCONNECTED:1,CONNECTING:2,CONNECTED:3,DISCONNECTED:4,HANDSHAKE:"handshake",RETRY:"retry",NONE:"none",CONNECTION_TIMEOUT:60,DEFAULT_RETRY:5,DEFAULT_ENDPOINT:"/bayeux",INTERVAL:0,initialize:function(e,t){this.info("New client created for ?",e),this._f=t||{},this.endpoint=e||this.DEFAULT_ENDPOINT,this.endpoints=this._f.endpoints||{},this.transports={},this._D=Faye.CookieJar&&new Faye.CookieJar,this._y={},this._o=[],this.retry=this._f.retry||this.DEFAULT_RETRY,this._1=this.UNCONNECTED,this._2=new Faye.Channel.Set,this._g=0,this._p={},this._9={reconnect:this.RETRY,interval:1e3*(this._f.interval||this.INTERVAL),timeout:1e3*(this._f.timeout||this.CONNECTION_TIMEOUT)},Faye.Event&&Faye.Event.on(Faye.ENV,"beforeunload",function(){Faye.indexOf(this._o,"autodisconnect")<0&&this.disconnect()},this)},disable:function(e){this._o.push(e)},setHeader:function(e,t){this._y[e]=t},getClientId:function(){return this._0},getState:function(){switch(this._1){case this.UNCONNECTED:return"UNCONNECTED";case this.CONNECTING:return"CONNECTING";case this.CONNECTED:return"CONNECTED";case this.DISCONNECTED:return"DISCONNECTED"}},handshake:function(e,t){if(this._9.reconnect===this.NONE)return;if(this._1!==this.UNCONNECTED)return;this._1=this.CONNECTING;var n=this;this.info("Initiating handshake with ?",this.endpoint),this._z(Faye.MANDATORY_CONNECTION_TYPES),this._a({channel:Faye.Channel.HANDSHAKE,version:Faye.BAYEUX_VERSION,supportedConnectionTypes:[this._5.connectionType]},function(r){r.successful?(this._1=this.CONNECTED,this._0=r.clientId,this._z(r.supportedConnectionTypes),this.info("Handshake successful: ?",this._0),this.subscribe(this._2.getKeys(),!0),e&&e.call(t)):(this.info("Handshake unsuccessful"),Faye.ENV.setTimeout(function(){n.handshake(e,t)},this._9.interval),this._1=this.UNCONNECTED)},this)},connect:function(e,t){if(this._9.reconnect===this.NONE)return;if(this._1===this.DISCONNECTED)return;if(this._1===this.UNCONNECTED)return this.handshake(function(){this.connect(e,t)},this);this.callback(e,t);if(this._1!==this.CONNECTED)return;this.info("Calling deferred actions for ?",this._0),this.setDeferredStatus("succeeded"),this.setDeferredStatus("deferred");if(this._q)return;this._q=!0,this.info("Initiating connection for ?",this._0),this._a({channel:Faye.Channel.CONNECT,clientId:this._0,connectionType:this._5.connectionType},this._A,this)},disconnect:function(){if(this._1!==this.CONNECTED)return;this._1=this.DISCONNECTED,this.info("Disconnecting ?",this._0),this._a({channel:Faye.Channel.DISCONNECT,clientId:this._0},function(e){e.successful&&this._5.close()},this),this.info("Clearing channel listeners for ?",this._0),this._2=new Faye.Channel.Set},subscribe:function(e,t,n){if(e instanceof Array)return Faye.map(e,function(e){return this.subscribe(e,t,n)},this);var r=new Faye.Subscription(this,e,t,n),i=t===!0,s=this._2.hasSubscription(e);return s&&!i?(this._2.subscribe([e],t,n),r.setDeferredStatus("succeeded"),r):(this.connect(function(){this.info("Client ? attempting to subscribe to ?",this._0,e),i||this._2.subscribe([e],t,n),this._a({channel:Faye.Channel.SUBSCRIBE,clientId:this._0,subscription:e},function(i){if(!i.successful)return r.setDeferredStatus("failed",Faye.Error.parse(i.error)),this._2.unsubscribe(e,t,n);var s=[].concat(i.subscription);this.info("Subscription acknowledged for ? to ?",this._0,s),r.setDeferredStatus("succeeded")},this)},this),r)},unsubscribe:function(e,t,n){if(e instanceof Array)return Faye.map(e,function(e){return this.unsubscribe(e,t,n)},this);var r=this._2.unsubscribe(e,t,n);if(!r)return;this.connect(function(){this.info("Client ? attempting to unsubscribe from ?",this._0,e),this._a({channel:Faye.Channel.UNSUBSCRIBE,clientId:this._0,subscription:e},function(e){if(!e.successful)return;var t=[].concat(e.subscription);this.info("Unsubscription acknowledged for ? from ?",this._0,t)},this)},this)},publish:function(e,t){var n=new Faye.Publication;return this.connect(function(){this.info("Client ? queueing published message to ?: ?",this._0,e,t),this._a({channel:e,data:t,clientId:this._0},function(e){e.successful?n.setDeferredStatus("succeeded"):n.setDeferredStatus("failed",Faye.Error.parse(e.error))},this)},this),n},receiveMessage:function(e){this.pipeThroughExtensions("incoming",e,function(e){if(!e)return;e.advice&&this._E(e.advice),this._F(e);if(e.successful===undefined)return;var t=this._p[e.id];if(!t)return;delete this._p[e.id],t[0].call(t[1],e)},this)},_z:function(e){Faye.Transport.get(this,e,this._o,function(e){this.debug("Selected ? transport for ?",e.connectionType,e.endpoint);if(e===this._5)return;this._5&&this._5.close(),this._5=e,this._5.cookies=this._D,this._5.headers=this._y,e.bind("down",function(){if(this._b!==undefined&&!this._b)return;this._b=!1,this.trigger("transport:down")},this),e.bind("up",function(){if(this._b!==undefined&&this._b)return;this._b=!0,this.trigger("transport:up")},this)},this)},_a:function(e,t,n){e.id=this._G(),t&&(this._p[e.id]=[t,n]),this.pipeThroughExtensions("outgoing",e,function(e){if(!e)return;this._5.send(e,this._9.timeout/1e3)},this)},_G:function(){return this._g+=1,this._g>=Math.pow(2,32)&&(this._g=0),this._g.toString(36)},_E:function(e){Faye.extend(this._9,e),this._9.reconnect===this.HANDSHAKE&&this._1!==this.DISCONNECTED&&(this._1=this.UNCONNECTED,this._0=null,this._A())},_F:function(e){if(!e.channel||e.data===undefined)return;this.info("Client ? calling listeners for ? with ?",this._0,e.channel,e.data),this._2.distributeMessage(e)},_H:function(){if(!this._q)return;this._q=null,this.info("Closed connection for ?",this._0)},_A:function(){this._H();var e=this;Faye.ENV.setTimeout(function(){e.connect()},this._9.interval)}}),Faye.extend(Faye.Client.prototype,Faye.Deferrable),Faye.extend(Faye.Client.prototype,Faye.Publisher),Faye.extend(Faye.Client.prototype,Faye.Logging),Faye.extend(Faye.Client.prototype,Faye.Extensible),Faye.Transport=Faye.extend(Faye.Class({MAX_DELAY:0,batching:!0,initialize:function(e,t){this._8=e,this.endpoint=t,this._c=[]},close:function(){},send:function(e,t){this.debug("Client ? sending message to ?: ?",this._8._0,this.endpoint,e);if(!this.batching)return this.request([e],t);this._c.push(e),this._I=t;if(e.channel===Faye.Channel.HANDSHAKE)return this.addTimeout("publish",.01,this.flush,this);e.channel===Faye.Channel.CONNECT&&(this._r=e);if(this.shouldFlush&&this.shouldFlush(this._c))return this.flush();this.addTimeout("publish",this.MAX_DELAY,this.flush,this)},flush:function(){this.removeTimeout("publish"),this._c.length>1&&this._r&&(this._r.advice={timeout:0}),this.request(this._c,this._I),this._r=null,this._c=[]},receive:function(e){this.debug("Client ? received from ?: ?",this._8._0,this.endpoint,e);for(var t=0,n=e.length;t<n;t++)this._8.receiveMessage(e[t])},retry:function(e,t){var n=!1,r=this._8.retry*1e3,i=this;return function(){if(n)return;n=!0,Faye.ENV.setTimeout(function(){i.request(e,t)},r)}}}),{MAX_URL_LENGTH:2048,get:function(e,t,n,r,i){var s=e.endpoint;Faye.asyncEach(this._B,function(u,a){var f=u[0],c=u[1],h=e.endpoints[f]||s;if(Faye.indexOf(n,f)>=0)return a();if(Faye.indexOf(t,f)<0)return c.isUsable(e,h,function(){}),a();c.isUsable(e,h,function(t){if(!t)return a();var n=c.hasOwnProperty("create")?c.create(e,h):new c(e,h);r.call(i,n)})},function(){throw new Error("Could not find a usable connection type for "+s)})},register:function(e,t){this._B.push([e,t]),t.prototype.connectionType=e},_B:[]}),Faye.extend(Faye.Transport.prototype,Faye.Logging),Faye.extend(Faye.Transport.prototype,Faye.Publisher),Faye.extend(Faye.Transport.prototype,Faye.Timeouts),Faye.Event={_h:[],on:function(e,t,n,r){var i=function(){n.call(r)};e.addEventListener?e.addEventListener(t,i,!1):e.attachEvent("on"+t,i),this._h.push({_i:e,_s:t,_m:n,_n:r,_C:i})},detach:function(e,t,n,r){var i=this._h.length,s;while(i--){s=this._h[i];if(e&&e!==s._i||t&&t!==s._s||n&&n!==s._m||r&&r!==s._n)continue;s._i.removeEventListener?s._i.removeEventListener(s._s,s._C,!1):s._i.detachEvent("on"+s._s,s._C),this._h.splice(i,1),s=null}}},Faye.Event.on(Faye.ENV,"unload",Faye.Event.detach,Faye.Event),Faye.URI=Faye.extend(Faye.Class({queryString:function(){var e=[];for(var t in this.params){if(!this.params.hasOwnProperty(t))continue;e.push(encodeURIComponent(t)+"="+encodeURIComponent(this.params[t]))}return e.join("&")},isSameOrigin:function(){var e=Faye.URI.parse(Faye.ENV.location.href,!1),t=e.hostname!==this.hostname||e.port!==this.port||e.protocol!==this.protocol;return!t},toURL:function(){var e=this.queryString();return this.protocol+"//"+this.hostname+(this.port?":"+this.port:"")+this.pathname+(e?"?"+e:"")+this.hash}}),{parse:function(e,t){if(typeof e!="string")return e;var n=new this,r,i=function(t,r,i){e=e.replace(r,function(e){return n[t]=e,""}),n[t]===undefined&&(n[t]=i?Faye.ENV.location[t]:"")};i("protocol",/^https?\:/,!0),i("host",/^\/\/[^\/]+/,!0),/^\//.test(e)||(e=Faye.ENV.location.pathname.replace(/[^\/]*$/,"")+e),i("pathname",/^\/[^\?#]*/),i("search",/^\?[^#]*/),i("hash",/^#.*/),/^\/\//.test(n.host)?(n.host=n.host.substr(2),r=n.host.split(":"),n.hostname=r[0],n.port=r[1]||""):(n.hostname=Faye.ENV.location.hostname,n.port=Faye.ENV.location.port);if(t===!1)n.params={};else{var s=n.search.replace(/^\?/,""),o=s?s.split("&"):[],u=o.length,a={};while(u--)r=o[u].split("="),a[decodeURIComponent(r[0]||"")]=decodeURIComponent(r[1]||"");typeof t=="object"&&Faye.extend(a,t),n.params=a}return n}}),this.JSON||(JSON={}),function(){function m(e){return e<10?"0"+e:e}function s(e){return o.lastIndex=0,o.test(e)?'"'+e.replace(o,function(e){var n=t[e];return typeof n=="string"?n:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function r(e,t){var n,i,o,u,a=l,f,c=t[e];c&&typeof c=="object"&&typeof c.toJSON=="function"&&(c=c.toJSON(e)),typeof p=="function"&&(c=p.call(t,e,c));switch(typeof c){case"string":return s(c);case"number":return isFinite(c)?String(c):"null";case"boolean":case"null":return String(c);case"object":if(!c)return"null";l+=q,f=[];if(Object.prototype.toString.apply(c)==="[object Array]"){u=c.length;for(n=0;n<u;n+=1)f[n]=r(n,c)||"null";return o=f.length===0?"[]":l?"[\n"+l+f.join(",\n"+l)+"\n"+a+"]":"["+f.join(",")+"]",l=a,o}if(p&&typeof p=="object"){u=p.length;for(n=0;n<u;n+=1)i=p[n],typeof i=="string"&&(o=r(i,c),o&&f.push(s(i)+(l?": ":":")+o))}else for(i in c)Object.hasOwnProperty.call(c,i)&&(o=r(i,c),o&&f.push(s(i)+(l?": ":":")+o));return o=f.length===0?"{}":l?"{\n"+l+f.join(",\n"+l)+"\n"+a+"}":"{"+f.join(",")+"}",l=a,o}}typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(e){return this.getUTCFullYear()+"-"+m(this.getUTCMonth()+1)+"-"+m(this.getUTCDate())+"T"+m(this.getUTCHours())+":"+m(this.getUTCMinutes())+":"+m(this.getUTCSeconds())+"Z"},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var n=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,l,q,t={"\b":"\\b","	":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},p;Faye.stringify=function(e,t,n){var i;l="",q="";if(typeof n=="number")for(i=0;i<n;i+=1)q+=" ";else typeof n=="string"&&(q=n);p=t;if(!t||typeof t=="function"||typeof t=="object"&&typeof t.length=="number")return r("",{"":e});throw new Error("JSON.stringify")},typeof JSON.stringify!="function"&&(JSON.stringify=Faye.stringify),typeof JSON.parse!="function"&&(JSON.parse=function(h,i){function j(e,t){var n,r,s=e[t];if(s&&typeof s=="object")for(n in s)Object.hasOwnProperty.call(s,n)&&(r=j(s,n),r!==undefined?s[n]=r:delete s[n]);return i.call(e,t,s)}var k;n.lastIndex=0,n.test(h)&&(h=h.replace(n,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(h.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return k=eval("("+h+")"),typeof i=="function"?j({"":k},""):k;throw new SyntaxError("JSON.parse")})}(),Faye.Transport.WebSocket=Faye.extend(Faye.Class(Faye.Transport,{UNCONNECTED:1,CONNECTING:2,CONNECTED:3,batching:!1,isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)}),this.connect()},request:function(e,t){if(e.length===0)return;this._d=this._d||{};for(var n=0,r=e.length;n<r;n++)this._d[e[n].id]=e[n];this.callback(function(t){t.send(Faye.toJSON(e))}),this.connect()},close:function(){if(!this._3)return;this._3.onclose=this._3.onerror=null,this._3.close(),delete this._3,this.setDeferredStatus("deferred"),this._1=this.UNCONNECTED},connect:function(){if(Faye.Transport.WebSocket._J)return;this._1=this._1||this.UNCONNECTED;if(this._1!==this.UNCONNECTED)return;this._1=this.CONNECTING;var e=Faye.Transport.WebSocket.getClass();if(!e)return this.setDeferredStatus("failed");this._3=new e(Faye.Transport.WebSocket.getSocketUrl(this.endpoint));var t=this;this._3.onopen=function(){t._1=t.CONNECTED,t._t=!0,t.setDeferredStatus("succeeded",t._3),t.trigger("up")},this._3.onmessage=function(e){var n=JSON.parse(e.data);if(!n)return;n=[].concat(n);for(var r=0,i=n.length;r<i;r++)delete t._d[n[r].id];t.receive(n)},this._3.onclose=this._3.onerror=function(){var e=t._1===t.CONNECTED;t.setDeferredStatus("deferred"),t._1=t.UNCONNECTED,t.close();if(e)return t.resend();if(!t._t)return t.setDeferredStatus("failed");var n=t._8.retry*1e3;Faye.ENV.setTimeout(function(){t.connect()},n),t.trigger("down")}},resend:function(){if(!this._d)return;var e=Faye.map(this._d,function(e,t){return t});this.request(e)}}),{getSocketUrl:function(e){return Faye.URI&&(e=Faye.URI.parse(e).toURL()),e.replace(/^http(s?):/ig,"ws$1:")},getClass:function(){return Faye.WebSocket&&Faye.WebSocket.Client||Faye.ENV.WebSocket||Faye.ENV.MozWebSocket},isUsable:function(e,t,n,r){this.create(e,t).isUsable(n,r)},create:function(e,t){var n=e.transports.websocket=e.transports.websocket||{};return n[t]=n[t]||new this(e,t),n[t]}}),Faye.extend(Faye.Transport.WebSocket.prototype,Faye.Deferrable),Faye.Transport.register("websocket",Faye.Transport.WebSocket),Faye.Event&&Faye.Event.on(Faye.ENV,"beforeunload",function(){Faye.Transport.WebSocket._J=!0}),Faye.Transport.EventSource=Faye.extend(Faye.Class(Faye.Transport,{initialize:function(e,t){Faye.Transport.prototype.initialize.call(this,e,t);if(!Faye.ENV.EventSource)return this.setDeferredStatus("failed");this._K=new Faye.Transport.XHR(e,t);var n=new EventSource(t+"/"+e.getClientId()),r=this;n.onopen=function(){r._t=!0,r.setDeferredStatus("succeeded"),r.trigger("up")},n.onerror=function(){r._t?r.trigger("down"):(r.setDeferredStatus("failed"),n.close())},n.onmessage=function(e){r.receive(JSON.parse(e.data)),r.trigger("up")},this._3=n},isUsable:function(e,t){this.callback(function(){e.call(t,!0)}),this.errback(function(){e.call(t,!1)})},request:function(e,t){this._K.request(e,t)},close:function(){if(!this._3)return;this._3.onerror=null,this._3.close(),delete this._3}}),{isUsable:function(e,t,n,r){var i=e.getClientId();if(!i)return n.call(r,!1);Faye.Transport.XHR.isUsable(e,t,function(i){if(!i)return n.call(r,!1);this.create(e,t).isUsable(n,r)},this)},create:function(e,t){var n=e.transports.eventsource=e.transports.eventsource||{},r=e.getClientId(),t=t+"/"+(r||"");return n[t]=n[t]||new this(e,t),n[t]}}),Faye.extend(Faye.Transport.EventSource.prototype,Faye.Deferrable),Faye.Transport.register("eventsource",Faye.Transport.EventSource),Faye.Transport.XHR=Faye.extend(Faye.Class(Faye.Transport,{request:function(e,t){var n=this.retry(e,t),r=Faye.URI.parse(this.endpoint).pathname,i=this,s=Faye.ENV.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest;s.open("POST",r,!0),s.setRequestHeader("Content-Type","application/json"),s.setRequestHeader("Pragma","no-cache"),s.setRequestHeader("X-Requested-With","XMLHttpRequest");var o=this.headers;for(var u in o){if(!o.hasOwnProperty(u))continue;s.setRequestHeader(u,o[u])}var a=function(){s.abort()};Faye.Event.on(Faye.ENV,"beforeunload",a);var f=function(){Faye.Event.detach(Faye.ENV,"beforeunload",a),s.onreadystatechange=function(){},s=null};s.onreadystatechange=function(){if(s.readyState!==4)return;var e=null,t=s.status,r=t>=200&&t<300||t===304||t===1223;if(!r)return f(),n(),i.trigger("down");try{e=JSON.parse(s.responseText)}catch(o){}f(),e?(i.receive(e),i.trigger("up")):(n(),i.trigger("down"))},s.send(Faye.toJSON(e))}}),{isUsable:function(e,t,n,r){n.call(r,Faye.URI.parse(t).isSameOrigin())}}),Faye.Transport.register("long-polling",Faye.Transport.XHR),Faye.Transport.CORS=Faye.extend(Faye.Class(Faye.Transport,{request:function(e,t){var n=Faye.ENV.XDomainRequest?XDomainRequest:XMLHttpRequest,r=new n,i=this.retry(e,t),s=this;r.open("POST",this.endpoint,!0),r.setRequestHeader&&r.setRequestHeader("Pragma","no-cache");var o=function(){return r?(r.onload=r.onerror=r.ontimeout=r.onprogress=null,r=null,Faye.ENV.clearTimeout(a),!0):!1};r.onload=function(){var e=null;try{e=JSON.parse(r.responseText)}catch(t){}o(),e?(s.receive(e),s.trigger("up")):(i(),s.trigger("down"))};var u=function(){o(),i(),s.trigger("down")},a=Faye.ENV.setTimeout(u,1500*t);r.onerror=u,r.ontimeout=u,r.onprogress=function(){},r.send("message="+encodeURIComponent(Faye.toJSON(e)))}}),{isUsable:function(e,t,n,r){if(Faye.URI.parse(t).isSameOrigin())return n.call(r,!1);if(Faye.ENV.XDomainRequest)return n.call(r,Faye.URI.parse(t).protocol===Faye.URI.parse(Faye.ENV.location).protocol);if(Faye.ENV.XMLHttpRequest){var i=new Faye.ENV.XMLHttpRequest;return n.call(r,i.withCredentials!==undefined)}return n.call(r,!1)}}),Faye.Transport.register("cross-origin-long-polling",Faye.Transport.CORS),Faye.Transport.JSONP=Faye.extend(Faye.Class(Faye.Transport,{shouldFlush:function(e){var t={message:Faye.toJSON(e),jsonp:"__jsonp"+Faye.Transport.JSONP._u+"__"},n=Faye.URI.parse(this.endpoint,t).toURL();return n.length>=Faye.Transport.MAX_URL_LENGTH},request:function(e,t){var n={message:Faye.toJSON(e)},r=document.getElementsByTagName("head")[0],i=document.createElement("script"),s=Faye.Transport.JSONP.getCallbackName(),o=Faye.URI.parse(this.endpoint,n),u=this.retry(e,t),a=this;Faye.ENV[s]=function(e){l(),a.receive(e),a.trigger("up")};var f=Faye.ENV.setTimeout(function(){l(),u(),a.trigger("down")},1500*t),l=function(){if(!Faye.ENV[s])return!1;Faye.ENV[s]=undefined;try{delete Faye.ENV[s]}catch(e){}return Faye.ENV.clearTimeout(f),i.parentNode.removeChild(i),!0};o.params.jsonp=s,i.type="text/javascript",i.src=o.toURL(),r.appendChild(i)}}),{_u:0,getCallbackName:function(){return this._u+=1,"__jsonp"+this._u+"__"},isUsable:function(e,t,n,r){n.call(r,!0)}}),Faye.Transport.register("callback-polling",Faye.Transport.JSONP),define("../node_modules/faye/browser/faye-browser-min.js",function(){});var requirejs=require("../node_modules/requirejs/require.js");requirejs.config({nodeRequire:require}),require(["../node_modules/faye/browser/faye-browser-min.js"],function(e){var t={VERSION:"1.0.0",DEFAULT_ENDPOINT:"http://localhost:9292/bayeux",DEFAULT_OPTIONS:{},extend:function(e,t,n){if(!t)return e;for(var r in t){if(!t.hasOwnProperty(r))continue;if(e.hasOwnProperty(r)&&!1===n)continue;e[r]!==t[r]&&(e[r]=t[r])}return e}};t.Class=function(e,n){var r,i;return"function"!=typeof e&&(n=e,e=Object),i=function(){return this.initialize?this.initialize.apply(this,arguments)||this:this},r=function(){},r.prototype=e.prototype,i.prototype=new r,t.extend(i.prototype,n,!0),i},t.Client=t.Class({initialize:function(t,n){this._fayeOptions=n||this.DEFAULT_OPTIONS,this._endpoint=t||this.DEFAULT_ENDPOINT,this._faye=new e.Client(this._endpoint,this._fayeOptions)},disable:function(e){if(!this._faye)return;this._faye.disable(e)},subscribe:function(e,t,n){return this._faye?(console.log('Subscribing to "'+this._endpoint+e+'"'),this._faye.subscribe(e,t,n)):!1},unsubscribe:function(e,t,n){return this._faye?(console.log('Unsubscribing from "'+this._endpoint+e+'"'),this._faye.unsubscribe(e,t,n)):!1},publish:function(e,t){return this._faye?(console.log('Publishing "'+t+'" to "'+this._endpoint+e+'"'),this._faye.publish(e,t)):!1}})}),define("main",function(){});
+module.exports = require('./scripts/main.js');
+{
+    "name"          : "lib-faye",
+    "description"   : "Faye service library for the DreamFactory Services Platform(tm)",
+    "version"       : "1.0.0",
+    "homepage"      : "http://github.com/dreamfactorysoftware/lib-faye",
+    "author"        : {
+        "name" : "Jerry Ablan",
+        "email": "jerryablan@dreamfactory.com"
+    },
+    "licenses"      : [
+        {
+            "type": "GPL3",
+            "url" : "https://github.com/dreamfactorysoftware/lib-faye/blob/master/LICENSE"
+        }
+    ],
+    "main"          : "index",
+    "engines"       : {
+        "node": ">=0.10.0"
+    },
+    "readmeFilename": "README.md"
+}
+({
+    appDir : '../',
+    baseUrl: 'scripts',
+    dir    : '../build',
+
+    optimize   : 'uglify',
+    optimizeCss: 'standard',
+
+    paths: {
+    },
+
+    modules: [
+        {
+            name: 'main'
+        }
+    ]
+
+})
+var requirejs = require('../node_modules/requirejs/require.js');
+
+requirejs.config({
+    nodeRequire: require
+});
+
+require(['../node_modules/faye/browser/faye-browser-min.js'], function(Faye) {
+
+    /*!
+     * FayeService
+     * An ultra-thin wrapper around the faye.js client
+     *
+     * @author Jerry Ablan <jerryablan@dreamfactory.com>
+     */
+    var FayeService = {
+
+        /**
+         * Version
+         */
+        VERSION         : '1.0.0',
+        /**
+         * Defaults
+         */
+        DEFAULT_ENDPOINT: 'http://localhost:9292/bayeux',
+        /**
+         * Default Faye options
+         */
+        DEFAULT_OPTIONS : {},
+
+        /**
+         * Extend
+         * @param dest
+         * @param source
+         * @param overwrite
+         * @returns {*}
+         */
+        extend: function(dest, source, overwrite) {
+            if (!source) {
+                return dest;
+            }
+
+            for (var key in source) {
+                if (!source.hasOwnProperty(key)) {
+                    continue;
+                }
+                if (dest.hasOwnProperty(key) && false === overwrite) {
+                    continue;
+                }
+                if (dest[key] !== source[key]) {
+                    dest[key] = source[key];
+                }
+            }
+            return dest;
+        }
+    };
+
+    /**
+     * Class Factory
+     * @param parent
+     * @param methods
+     * @returns {Function}
+     * @constructor
+     */
+    FayeService.Class = function(parent, methods) {
+        var bridge;
+        var fayeClass;
+
+        if ('function' !== typeof parent) {
+            methods = parent;
+            parent = Object;
+        }
+
+        fayeClass = function() {
+            if (!this.initialize) {
+                return this;
+            }
+
+            return this.initialize.apply(this, arguments) || this;
+        };
+
+        bridge = function() {
+        };
+
+        bridge.prototype = parent.prototype;
+        fayeClass.prototype = new bridge();
+
+        FayeService.extend(fayeClass.prototype, methods, true);
+
+        return fayeClass;
+    };
+
+    /**
+     * Client class
+     * @type {*}
+     */
+    FayeService.Client = FayeService.Class({
+
+        /**
+         * Initialize
+         */
+        initialize: function(endpoint, fayeOptions) {
+            this._fayeOptions = fayeOptions || this.DEFAULT_OPTIONS;
+            this._endpoint = endpoint || this.DEFAULT_ENDPOINT;
+            this._faye = new Faye.Client(this._endpoint, this._fayeOptions);
+        },
+
+        /**
+         * Disable communication
+         * @param feature
+         */
+        disable: function(feature) {
+            if (!this._faye) {
+                return;
+            }
+
+            this._faye.disable(feature);
+        },
+
+        /**
+         *
+         * @param channel
+         * @param callback
+         * @param context
+         * @returns {boolean|Faye.Subscription}
+         */
+        subscribe: function(channel, callback, context) {
+            if (!this._faye) {
+                return false;
+            }
+
+            console.log('Subscribing to "' + this._endpoint + channel + '"');
+            return this._faye.subscribe(channel, callback, context);
+        },
+
+        /**
+         *
+         * @param channel
+         * @param callback
+         * @param context
+         * @returns {boolean|Faye.Subscription}
+         */
+        unsubscribe: function(channel, callback, context) {
+            if (!this._faye) {
+                return false;
+            }
+
+            console.log('Unsubscribing from "' + this._endpoint + channel + '"');
+            return this._faye.unsubscribe(channel, callback, context);
+        },
+
+        /**
+         * @param channel
+         * @param message
+         * @returns {boolean|Faye.Publication}
+         */
+        publish: function(channel, message) {
+            if (!this._faye) {
+                return false;
+            }
+
+            console.log('Publishing "' + message + '" to "' + this._endpoint + channel + '"');
+            return this._faye.publish(channel, message);
+        }
+
+    });
+
+});