A Websocket, EventSource, and Long-Polling wrapper for Nchan
// CommonJSlet NchanSubscriber = ;// you can also include the NchanSubscriber.js script directly in the browser.// This will export NchanSubscriber as a global variable.var sub = url opt;//optionsopt =subscriber: 'longpoll' 'eventsource' or 'websocket'//or an array of the above indicating subscriber type preferencereconnect: undefined or 'session' or 'persist'//if the HTML5 sessionStore or localStore should be used to resume//connections interrupted by a page loadshared: true or undefined//share connection to same subscriber url between browser//windows and tabs using localStorage. In shared mode,//only 1 running subscriber is allowed per url per window/tab.sub;sub;sub;sub;subreconnect; // should subscriber try to reconnect? true by default.subreconnectTimeout; //how long to wait to reconnect? does not apply to EventSource, which reconnects on its own.sublastMessageId; //last message id. useful for resuming a connection without loss or repetition.substart; // begin (or resume) subscribingsub; // stop subscriber. do not reconnect.