12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856 |
- /* eslint-disable */
- /**
- * To use sails.io.js in an AMD environment (e.g. with require.js),
- * replace this file with the sails.io.js file from the root of:
- * https://github.com/balderdashy/sails.io.js
- * and download a standalone copy of socket.io-client from:
- * https://github.com/socketio/socket.io-client
- * then follow the instructions at:
- * https://github.com/balderdashy/sails.io.js#requirejsamd-usage
- */
- // socket.io-client version 1.7.3
- // https://github.com/socketio/socket.io-client
- !
- function(a, b) {
- "object" == typeof exports && "object" == typeof module ? module.exports = b() : "function" == typeof define && define.amd ? define([], b) : "object" == typeof exports ? exports.io = b() : a.io = b()
- } (this,
- function() {
- return function(a) {
- function b(d) {
- if (c[d]) return c[d].exports;
- var e = c[d] = {
- exports: {},
- id: d,
- loaded: !1
- };
- return a[d].call(e.exports, e, e.exports, b),
- e.loaded = !0,
- e.exports
- }
- var c = {};
- return b.m = a,
- b.c = c,
- b.p = "",
- b(0)
- } ([function(a, b, c) {
- "use strict";
- function d(a, b) {
- "object" === ("undefined" == typeof a ? "undefined": f(a)) && (b = a, a = void 0),
- b = b || {};
- var c, d = g(a),
- h = d.source,
- l = d.id,
- m = d.path,
- n = k[l] && m in k[l].nsps,
- o = b.forceNew || b["force new connection"] || !1 === b.multiplex || n;
- return o ? (j("ignoring socket cache for %s", h), c = i(h, b)) : (k[l] || (j("new io instance for %s", h), k[l] = i(h, b)), c = k[l]),
- d.query && !b.query ? b.query = d.query: b && "object" === f(b.query) && (b.query = e(b.query)),
- c.socket(d.path, b)
- }
- function e(a) {
- var b = [];
- for (var c in a) a.hasOwnProperty(c) && b.push(encodeURIComponent(c) + "=" + encodeURIComponent(a[c]));
- return b.join("&")
- }
- var f = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
- function(a) {
- return typeof a
- }: function(a) {
- return a && "function" == typeof Symbol && a.constructor === Symbol && a !== Symbol.prototype ? "symbol": typeof a
- },
- g = c(1),
- h = c(7),
- i = c(17),
- j = c(3)("socket.io-client");
- a.exports = b = d;
- var k = b.managers = {};
- b.protocol = h.protocol,
- b.connect = d,
- b.Manager = c(17),
- b.Socket = c(44)
- },
- function(a, b, c) { (function(b) {
- "use strict";
- function d(a, c) {
- var d = a;
- c = c || b.location,
- null == a && (a = c.protocol + "//" + c.host),
- "string" == typeof a && ("/" === a.charAt(0) && (a = "/" === a.charAt(1) ? c.protocol + a: c.host + a), /^(https?|wss?):\/\//.test(a) || (f("protocol-less url %s", a), a = "undefined" != typeof c ? c.protocol + "//" + a: "https://" + a), f("parse %s", a), d = e(a)),
- d.port || (/^(http|ws)$/.test(d.protocol) ? d.port = "80": /^(http|ws)s$/.test(d.protocol) && (d.port = "443")),
- d.path = d.path || "/";
- var g = d.host.indexOf(":") !== -1,
- h = g ? "[" + d.host + "]": d.host;
- return d.id = d.protocol + "://" + h + ":" + d.port,
- d.href = d.protocol + "://" + h + (c && c.port === d.port ? "": ":" + d.port),
- d
- }
- var e = c(2),
- f = c(3)("socket.io-client:url");
- a.exports = d
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b) {
- var c = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,
- d = ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"];
- a.exports = function(a) {
- var b = a,
- e = a.indexOf("["),
- f = a.indexOf("]");
- e != -1 && f != -1 && (a = a.substring(0, e) + a.substring(e, f).replace(/:/g, ";") + a.substring(f, a.length));
- for (var g = c.exec(a || ""), h = {},
- i = 14; i--;) h[d[i]] = g[i] || "";
- return e != -1 && f != -1 && (h.source = b, h.host = h.host.substring(1, h.host.length - 1).replace(/;/g, ":"), h.authority = h.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), h.ipv6uri = !0),
- h
- }
- },
- function(a, b, c) { (function(d) {
- function e() {
- return "undefined" != typeof document && "WebkitAppearance" in document.documentElement.style || window.console && (console.firebug || console.exception && console.table) || navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31
- }
- function f() {
- var a = arguments,
- c = this.useColors;
- if (a[0] = (c ? "%c": "") + this.namespace + (c ? " %c": " ") + a[0] + (c ? "%c ": " ") + "+" + b.humanize(this.diff), !c) return a;
- var d = "color: " + this.color;
- a = [a[0], d, "color: inherit"].concat(Array.prototype.slice.call(a, 1));
- var e = 0,
- f = 0;
- return a[0].replace(/%[a-z%]/g,
- function(a) {
- "%%" !== a && (e++, "%c" === a && (f = e))
- }),
- a.splice(f, 0, d),
- a
- }
- function g() {
- return "object" == typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments)
- }
- function h(a) {
- try {
- null == a ? b.storage.removeItem("debug") : b.storage.debug = a
- } catch(c) {}
- }
- function i() {
- try {
- return b.storage.debug
- } catch(a) {}
- if ("undefined" != typeof d && "env" in d) return d.env.DEBUG
- }
- function j() {
- try {
- return window.localStorage
- } catch(a) {}
- }
- b = a.exports = c(5),
- b.log = g,
- b.formatArgs = f,
- b.save = h,
- b.load = i,
- b.useColors = e,
- b.storage = "undefined" != typeof chrome && "undefined" != typeof chrome.storage ? chrome.storage.local: j(),
- b.colors = ["lightseagreen", "forestgreen", "goldenrod", "dodgerblue", "darkorchid", "crimson"],
- b.formatters.j = function(a) {
- try {
- return JSON.stringify(a)
- } catch(b) {
- return "[UnexpectedJSONParseError]: " + b.message
- }
- },
- b.enable(i())
- }).call(b, c(4))
- },
- function(a, b) {
- function c() {
- throw new Error("setTimeout has not been defined")
- }
- function d() {
- throw new Error("clearTimeout has not been defined")
- }
- function e(a) {
- if (k === setTimeout) return setTimeout(a, 0);
- if ((k === c || !k) && setTimeout) return k = setTimeout,
- setTimeout(a, 0);
- try {
- return k(a, 0)
- } catch(b) {
- try {
- return k.call(null, a, 0)
- } catch(b) {
- return k.call(this, a, 0)
- }
- }
- }
- function f(a) {
- if (l === clearTimeout) return clearTimeout(a);
- if ((l === d || !l) && clearTimeout) return l = clearTimeout,
- clearTimeout(a);
- try {
- return l(a)
- } catch(b) {
- try {
- return l.call(null, a)
- } catch(b) {
- return l.call(this, a)
- }
- }
- }
- function g() {
- p && n && (p = !1, n.length ? o = n.concat(o) : q = -1, o.length && h())
- }
- function h() {
- if (!p) {
- var a = e(g);
- p = !0;
- for (var b = o.length; b;) {
- for (n = o, o = []; ++q < b;) n && n[q].run();
- q = -1,
- b = o.length
- }
- n = null,
- p = !1,
- f(a)
- }
- }
- function i(a, b) {
- this.fun = a,
- this.array = b
- }
- function j() {}
- var k, l, m = a.exports = {}; !
- function() {
- try {
- k = "function" == typeof setTimeout ? setTimeout: c
- } catch(a) {
- k = c
- }
- try {
- l = "function" == typeof clearTimeout ? clearTimeout: d
- } catch(a) {
- l = d
- }
- } ();
- var n, o = [],
- p = !1,
- q = -1;
- m.nextTick = function(a) {
- var b = new Array(arguments.length - 1);
- if (arguments.length > 1) for (var c = 1; c < arguments.length; c++) b[c - 1] = arguments[c];
- o.push(new i(a, b)),
- 1 !== o.length || p || e(h)
- },
- i.prototype.run = function() {
- this.fun.apply(null, this.array)
- },
- m.title = "browser",
- m.browser = !0,
- m.env = {},
- m.argv = [],
- m.version = "",
- m.versions = {},
- m.on = j,
- m.addListener = j,
- m.once = j,
- m.off = j,
- m.removeListener = j,
- m.removeAllListeners = j,
- m.emit = j,
- m.binding = function(a) {
- throw new Error("process.binding is not supported")
- },
- m.cwd = function() {
- return "/"
- },
- m.chdir = function(a) {
- throw new Error("process.chdir is not supported")
- },
- m.umask = function() {
- return 0
- }
- },
- function(a, b, c) {
- function d() {
- return b.colors[k++%b.colors.length]
- }
- function e(a) {
- function c() {}
- function e() {
- var a = e,
- c = +new Date,
- f = c - (j || c);
- a.diff = f,
- a.prev = j,
- a.curr = c,
- j = c,
- null == a.useColors && (a.useColors = b.useColors()),
- null == a.color && a.useColors && (a.color = d());
- for (var g = new Array(arguments.length), h = 0; h < g.length; h++) g[h] = arguments[h];
- g[0] = b.coerce(g[0]),
- "string" != typeof g[0] && (g = ["%o"].concat(g));
- var i = 0;
- g[0] = g[0].replace(/%([a-z%])/g,
- function(c, d) {
- if ("%%" === c) return c;
- i++;
- var e = b.formatters[d];
- if ("function" == typeof e) {
- var f = g[i];
- c = e.call(a, f),
- g.splice(i, 1),
- i--
- }
- return c
- }),
- g = b.formatArgs.apply(a, g);
- var k = e.log || b.log || console.log.bind(console);
- k.apply(a, g)
- }
- c.enabled = !1,
- e.enabled = !0;
- var f = b.enabled(a) ? e: c;
- return f.namespace = a,
- f
- }
- function f(a) {
- b.save(a);
- for (var c = (a || "").split(/[\s,]+/), d = c.length, e = 0; e < d; e++) c[e] && (a = c[e].replace(/[\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*?"), "-" === a[0] ? b.skips.push(new RegExp("^" + a.substr(1) + "$")) : b.names.push(new RegExp("^" + a + "$")))
- }
- function g() {
- b.enable("")
- }
- function h(a) {
- var c, d;
- for (c = 0, d = b.skips.length; c < d; c++) if (b.skips[c].test(a)) return ! 1;
- for (c = 0, d = b.names.length; c < d; c++) if (b.names[c].test(a)) return ! 0;
- return ! 1
- }
- function i(a) {
- return a instanceof Error ? a.stack || a.message: a
- }
- b = a.exports = e.debug = e,
- b.coerce = i,
- b.disable = g,
- b.enable = f,
- b.enabled = h,
- b.humanize = c(6),
- b.names = [],
- b.skips = [],
- b.formatters = {};
- var j, k = 0
- },
- function(a, b) {
- function c(a) {
- if (a = String(a), !(a.length > 1e4)) {
- var b = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(a);
- if (b) {
- var c = parseFloat(b[1]),
- d = (b[2] || "ms").toLowerCase();
- switch (d) {
- case "years":
- case "year":
- case "yrs":
- case "yr":
- case "y":
- return c * k;
- case "days":
- case "day":
- case "d":
- return c * j;
- case "hours":
- case "hour":
- case "hrs":
- case "hr":
- case "h":
- return c * i;
- case "minutes":
- case "minute":
- case "mins":
- case "min":
- case "m":
- return c * h;
- case "seconds":
- case "second":
- case "secs":
- case "sec":
- case "s":
- return c * g;
- case "milliseconds":
- case "millisecond":
- case "msecs":
- case "msec":
- case "ms":
- return c;
- default:
- return
- }
- }
- }
- }
- function d(a) {
- return a >= j ? Math.round(a / j) + "d": a >= i ? Math.round(a / i) + "h": a >= h ? Math.round(a / h) + "m": a >= g ? Math.round(a / g) + "s": a + "ms"
- }
- function e(a) {
- return f(a, j, "day") || f(a, i, "hour") || f(a, h, "minute") || f(a, g, "second") || a + " ms"
- }
- function f(a, b, c) {
- if (! (a < b)) return a < 1.5 * b ? Math.floor(a / b) + " " + c: Math.ceil(a / b) + " " + c + "s"
- }
- var g = 1e3,
- h = 60 * g,
- i = 60 * h,
- j = 24 * i,
- k = 365.25 * j;
- a.exports = function(a, b) {
- b = b || {};
- var f = typeof a;
- if ("string" === f && a.length > 0) return c(a);
- if ("number" === f && isNaN(a) === !1) return b["long"] ? e(a) : d(a);
- throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(a))
- }
- },
- function(a, b, c) {
- function d() {}
- function e(a) {
- var c = "",
- d = !1;
- return c += a.type,
- b.BINARY_EVENT != a.type && b.BINARY_ACK != a.type || (c += a.attachments, c += "-"),
- a.nsp && "/" != a.nsp && (d = !0, c += a.nsp),
- null != a.id && (d && (c += ",", d = !1), c += a.id),
- null != a.data && (d && (c += ","), c += m.stringify(a.data)),
- l("encoded %j as %s", a, c),
- c
- }
- function f(a, b) {
- function c(a) {
- var c = o.deconstructPacket(a),
- d = e(c.packet),
- f = c.buffers;
- f.unshift(d),
- b(f)
- }
- o.removeBlobs(a, c)
- }
- function g() {
- this.reconstructor = null
- }
- function h(a) {
- var c = {},
- d = 0;
- if (c.type = Number(a.charAt(0)), null == b.types[c.type]) return k();
- if (b.BINARY_EVENT == c.type || b.BINARY_ACK == c.type) {
- for (var e = "";
- "-" != a.charAt(++d) && (e += a.charAt(d), d != a.length););
- if (e != Number(e) || "-" != a.charAt(d)) throw new Error("Illegal attachments");
- c.attachments = Number(e)
- }
- if ("/" == a.charAt(d + 1)) for (c.nsp = ""; ++d;) {
- var f = a.charAt(d);
- if ("," == f) break;
- if (c.nsp += f, d == a.length) break
- } else c.nsp = "/";
- var g = a.charAt(d + 1);
- if ("" !== g && Number(g) == g) {
- for (c.id = ""; ++d;) {
- var f = a.charAt(d);
- if (null == f || Number(f) != f) {--d;
- break
- }
- if (c.id += a.charAt(d), d == a.length) break
- }
- c.id = Number(c.id)
- }
- return a.charAt(++d) && (c = i(c, a.substr(d))),
- l("decoded %s as %j", a, c),
- c
- }
- function i(a, b) {
- try {
- a.data = m.parse(b)
- } catch(c) {
- return k()
- }
- return a
- }
- function j(a) {
- this.reconPack = a,
- this.buffers = []
- }
- function k(a) {
- return {
- type: b.ERROR,
- data: "parser error"
- }
- }
- var l = c(8)("socket.io-parser"),
- m = c(11),
- n = c(13),
- o = c(14),
- p = c(16);
- b.protocol = 4,
- b.types = ["CONNECT", "DISCONNECT", "EVENT", "ACK", "ERROR", "BINARY_EVENT", "BINARY_ACK"],
- b.CONNECT = 0,
- b.DISCONNECT = 1,
- b.EVENT = 2,
- b.ACK = 3,
- b.ERROR = 4,
- b.BINARY_EVENT = 5,
- b.BINARY_ACK = 6,
- b.Encoder = d,
- b.Decoder = g,
- d.prototype.encode = function(a, c) {
- if (l("encoding packet %j", a), b.BINARY_EVENT == a.type || b.BINARY_ACK == a.type) f(a, c);
- else {
- var d = e(a);
- c([d])
- }
- },
- n(g.prototype),
- g.prototype.add = function(a) {
- var c;
- if ("string" == typeof a) c = h(a),
- b.BINARY_EVENT == c.type || b.BINARY_ACK == c.type ? (this.reconstructor = new j(c), 0 === this.reconstructor.reconPack.attachments && this.emit("decoded", c)) : this.emit("decoded", c);
- else {
- if (!p(a) && !a.base64) throw new Error("Unknown type: " + a);
- if (!this.reconstructor) throw new Error("got binary data when not reconstructing a packet");
- c = this.reconstructor.takeBinaryData(a),
- c && (this.reconstructor = null, this.emit("decoded", c))
- }
- },
- g.prototype.destroy = function() {
- this.reconstructor && this.reconstructor.finishedReconstruction()
- },
- j.prototype.takeBinaryData = function(a) {
- if (this.buffers.push(a), this.buffers.length == this.reconPack.attachments) {
- var b = o.reconstructPacket(this.reconPack, this.buffers);
- return this.finishedReconstruction(),
- b
- }
- return null
- },
- j.prototype.finishedReconstruction = function() {
- this.reconPack = null,
- this.buffers = []
- }
- },
- function(a, b, c) {
- function d() {
- return "WebkitAppearance" in document.documentElement.style || window.console && (console.firebug || console.exception && console.table) || navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31
- }
- function e() {
- var a = arguments,
- c = this.useColors;
- if (a[0] = (c ? "%c": "") + this.namespace + (c ? " %c": " ") + a[0] + (c ? "%c ": " ") + "+" + b.humanize(this.diff), !c) return a;
- var d = "color: " + this.color;
- a = [a[0], d, "color: inherit"].concat(Array.prototype.slice.call(a, 1));
- var e = 0,
- f = 0;
- return a[0].replace(/%[a-z%]/g,
- function(a) {
- "%%" !== a && (e++, "%c" === a && (f = e))
- }),
- a.splice(f, 0, d),
- a
- }
- function f() {
- return "object" == typeof console && console.log && Function.prototype.apply.call(console.log, console, arguments)
- }
- function g(a) {
- try {
- null == a ? b.storage.removeItem("debug") : b.storage.debug = a
- } catch(c) {}
- }
- function h() {
- var a;
- try {
- a = b.storage.debug
- } catch(c) {}
- return a
- }
- function i() {
- try {
- return window.localStorage
- } catch(a) {}
- }
- b = a.exports = c(9),
- b.log = f,
- b.formatArgs = e,
- b.save = g,
- b.load = h,
- b.useColors = d,
- b.storage = "undefined" != typeof chrome && "undefined" != typeof chrome.storage ? chrome.storage.local: i(),
- b.colors = ["lightseagreen", "forestgreen", "goldenrod", "dodgerblue", "darkorchid", "crimson"],
- b.formatters.j = function(a) {
- return JSON.stringify(a)
- },
- b.enable(h())
- },
- function(a, b, c) {
- function d() {
- return b.colors[k++%b.colors.length]
- }
- function e(a) {
- function c() {}
- function e() {
- var a = e,
- c = +new Date,
- f = c - (j || c);
- a.diff = f,
- a.prev = j,
- a.curr = c,
- j = c,
- null == a.useColors && (a.useColors = b.useColors()),
- null == a.color && a.useColors && (a.color = d());
- var g = Array.prototype.slice.call(arguments);
- g[0] = b.coerce(g[0]),
- "string" != typeof g[0] && (g = ["%o"].concat(g));
- var h = 0;
- g[0] = g[0].replace(/%([a-z%])/g,
- function(c, d) {
- if ("%%" === c) return c;
- h++;
- var e = b.formatters[d];
- if ("function" == typeof e) {
- var f = g[h];
- c = e.call(a, f),
- g.splice(h, 1),
- h--
- }
- return c
- }),
- "function" == typeof b.formatArgs && (g = b.formatArgs.apply(a, g));
- var i = e.log || b.log || console.log.bind(console);
- i.apply(a, g)
- }
- c.enabled = !1,
- e.enabled = !0;
- var f = b.enabled(a) ? e: c;
- return f.namespace = a,
- f
- }
- function f(a) {
- b.save(a);
- for (var c = (a || "").split(/[\s,]+/), d = c.length, e = 0; e < d; e++) c[e] && (a = c[e].replace(/\*/g, ".*?"), "-" === a[0] ? b.skips.push(new RegExp("^" + a.substr(1) + "$")) : b.names.push(new RegExp("^" + a + "$")))
- }
- function g() {
- b.enable("")
- }
- function h(a) {
- var c, d;
- for (c = 0, d = b.skips.length; c < d; c++) if (b.skips[c].test(a)) return ! 1;
- for (c = 0, d = b.names.length; c < d; c++) if (b.names[c].test(a)) return ! 0;
- return ! 1
- }
- function i(a) {
- return a instanceof Error ? a.stack || a.message: a
- }
- b = a.exports = e,
- b.coerce = i,
- b.disable = g,
- b.enable = f,
- b.enabled = h,
- b.humanize = c(10),
- b.names = [],
- b.skips = [],
- b.formatters = {};
- var j, k = 0
- },
- function(a, b) {
- function c(a) {
- if (a = "" + a, !(a.length > 1e4)) {
- var b = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(a);
- if (b) {
- var c = parseFloat(b[1]),
- d = (b[2] || "ms").toLowerCase();
- switch (d) {
- case "years":
- case "year":
- case "yrs":
- case "yr":
- case "y":
- return c * k;
- case "days":
- case "day":
- case "d":
- return c * j;
- case "hours":
- case "hour":
- case "hrs":
- case "hr":
- case "h":
- return c * i;
- case "minutes":
- case "minute":
- case "mins":
- case "min":
- case "m":
- return c * h;
- case "seconds":
- case "second":
- case "secs":
- case "sec":
- case "s":
- return c * g;
- case "milliseconds":
- case "millisecond":
- case "msecs":
- case "msec":
- case "ms":
- return c
- }
- }
- }
- }
- function d(a) {
- return a >= j ? Math.round(a / j) + "d": a >= i ? Math.round(a / i) + "h": a >= h ? Math.round(a / h) + "m": a >= g ? Math.round(a / g) + "s": a + "ms"
- }
- function e(a) {
- return f(a, j, "day") || f(a, i, "hour") || f(a, h, "minute") || f(a, g, "second") || a + " ms"
- }
- function f(a, b, c) {
- if (! (a < b)) return a < 1.5 * b ? Math.floor(a / b) + " " + c: Math.ceil(a / b) + " " + c + "s"
- }
- var g = 1e3,
- h = 60 * g,
- i = 60 * h,
- j = 24 * i,
- k = 365.25 * j;
- a.exports = function(a, b) {
- return b = b || {},
- "string" == typeof a ? c(a) : b["long"] ? e(a) : d(a)
- }
- },
- function(a, b, c) { (function(a, c) {
- var d = !1; (function() {
- function e(a, b) {
- function c(a) {
- if (c[a] !== q) return c[a];
- var e;
- if ("bug-string-char-index" == a) e = "a" != "a" [0];
- else if ("json" == a) e = c("json-stringify") && c("json-parse");
- else {
- var g, h = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
- if ("json-stringify" == a) {
- var i = b.stringify,
- k = "function" == typeof i && t;
- if (k) { (g = function() {
- return 1
- }).toJSON = g;
- try {
- k = "0" === i(0) && "0" === i(new d) && '""' == i(new f) && i(s) === q && i(q) === q && i() === q && "1" === i(g) && "[1]" == i([g]) && "[null]" == i([q]) && "null" == i(null) && "[null,null,null]" == i([q, s, null]) && i({
- a: [g, !0, !1, null, "\0\b\n\f\r\t"]
- }) == h && "1" === i(null, g) && "[\n 1,\n 2\n]" == i([1, 2], null, 1) && '"-271821-04-20T00:00:00.000Z"' == i(new j(( - 864e13))) && '"+275760-09-13T00:00:00.000Z"' == i(new j(864e13)) && '"-000001-01-01T00:00:00.000Z"' == i(new j(( - 621987552e5))) && '"1969-12-31T23:59:59.999Z"' == i(new j(( - 1)))
- } catch(l) {
- k = !1
- }
- }
- e = k
- }
- if ("json-parse" == a) {
- var m = b.parse;
- if ("function" == typeof m) try {
- if (0 === m("0") && !m(!1)) {
- g = m(h);
- var n = 5 == g.a.length && 1 === g.a[0];
- if (n) {
- try {
- n = !m('"\t"')
- } catch(l) {}
- if (n) try {
- n = 1 !== m("01")
- } catch(l) {}
- if (n) try {
- n = 1 !== m("1.")
- } catch(l) {}
- }
- }
- } catch(l) {
- n = !1
- }
- e = n
- }
- }
- return c[a] = !!e
- }
- a || (a = i.Object()),
- b || (b = i.Object());
- var d = a.Number || i.Number,
- f = a.String || i.String,
- h = a.Object || i.Object,
- j = a.Date || i.Date,
- k = a.SyntaxError || i.SyntaxError,
- l = a.TypeError || i.TypeError,
- m = a.Math || i.Math,
- n = a.JSON || i.JSON;
- "object" == typeof n && n && (b.stringify = n.stringify, b.parse = n.parse);
- var o, p, q, r = h.prototype,
- s = r.toString,
- t = new j(( - 0xc782b5b800cec));
- try {
- t = t.getUTCFullYear() == -109252 && 0 === t.getUTCMonth() && 1 === t.getUTCDate() && 10 == t.getUTCHours() && 37 == t.getUTCMinutes() && 6 == t.getUTCSeconds() && 708 == t.getUTCMilliseconds()
- } catch(u) {}
- if (!c("json")) {
- var v = "[object Function]",
- w = "[object Date]",
- x = "[object Number]",
- y = "[object String]",
- z = "[object Array]",
- A = "[object Boolean]",
- B = c("bug-string-char-index");
- if (!t) var C = m.floor,
- D = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334],
- E = function(a, b) {
- return D[b] + 365 * (a - 1970) + C((a - 1969 + (b = +(b > 1))) / 4) - C((a - 1901 + b) / 100) + C((a - 1601 + b) / 400)
- };
- if ((o = r.hasOwnProperty) || (o = function(a) {
- var b, c = {};
- return (c.__proto__ = null, c.__proto__ = {
- toString: 1
- },
- c).toString != s ? o = function(a) {
- var b = this.__proto__,
- c = a in (this.__proto__ = null, this);
- return this.__proto__ = b,
- c
- }: (b = c.constructor, o = function(a) {
- var c = (this.constructor || b).prototype;
- return a in this && !(a in c && this[a] === c[a])
- }),
- c = null,
- o.call(this, a)
- }), p = function(a, b) {
- var c, d, e, f = 0; (c = function() {
- this.valueOf = 0
- }).prototype.valueOf = 0,
- d = new c;
- for (e in d) o.call(d, e) && f++;
- return c = d = null,
- f ? p = 2 == f ?
- function(a, b) {
- var c, d = {},
- e = s.call(a) == v;
- for (c in a) e && "prototype" == c || o.call(d, c) || !(d[c] = 1) || !o.call(a, c) || b(c)
- }: function(a, b) {
- var c, d, e = s.call(a) == v;
- for (c in a) e && "prototype" == c || !o.call(a, c) || (d = "constructor" === c) || b(c); (d || o.call(a, c = "constructor")) && b(c)
- }: (d = ["valueOf", "toString", "toLocaleString", "propertyIsEnumerable", "isPrototypeOf", "hasOwnProperty", "constructor"], p = function(a, b) {
- var c, e, f = s.call(a) == v,
- h = !f && "function" != typeof a.constructor && g[typeof a.hasOwnProperty] && a.hasOwnProperty || o;
- for (c in a) f && "prototype" == c || !h.call(a, c) || b(c);
- for (e = d.length; c = d[--e]; h.call(a, c) && b(c));
- }),
- p(a, b)
- },
- !c("json-stringify")) {
- var F = {
- 92 : "\\\\",
- 34 : '\\"',
- 8 : "\\b",
- 12 : "\\f",
- 10 : "\\n",
- 13 : "\\r",
- 9 : "\\t"
- },
- G = "000000",
- H = function(a, b) {
- return (G + (b || 0)).slice( - a)
- },
- I = "\\u00",
- J = function(a) {
- for (var b = '"',
- c = 0,
- d = a.length,
- e = !B || d > 10,
- f = e && (B ? a.split("") : a); c < d; c++) {
- var g = a.charCodeAt(c);
- switch (g) {
- case 8:
- case 9:
- case 10:
- case 12:
- case 13:
- case 34:
- case 92:
- b += F[g];
- break;
- default:
- if (g < 32) {
- b += I + H(2, g.toString(16));
- break
- }
- b += e ? f[c] : a.charAt(c)
- }
- }
- return b + '"'
- },
- K = function(a, b, c, d, e, f, g) {
- var h, i, j, k, m, n, r, t, u, v, B, D, F, G, I, L;
- try {
- h = b[a]
- } catch(M) {}
- if ("object" == typeof h && h) if (i = s.call(h), i != w || o.call(h, "toJSON"))"function" == typeof h.toJSON && (i != x && i != y && i != z || o.call(h, "toJSON")) && (h = h.toJSON(a));
- else if (h > -1 / 0 && h < 1 / 0) {
- if (E) {
- for (m = C(h / 864e5), j = C(m / 365.2425) + 1970 - 1; E(j + 1, 0) <= m; j++);
- for (k = C((m - E(j, 0)) / 30.42); E(j, k + 1) <= m; k++);
- m = 1 + m - E(j, k),
- n = (h % 864e5 + 864e5) % 864e5,
- r = C(n / 36e5) % 24,
- t = C(n / 6e4) % 60,
- u = C(n / 1e3) % 60,
- v = n % 1e3
- } else j = h.getUTCFullYear(),
- k = h.getUTCMonth(),
- m = h.getUTCDate(),
- r = h.getUTCHours(),
- t = h.getUTCMinutes(),
- u = h.getUTCSeconds(),
- v = h.getUTCMilliseconds();
- h = (j <= 0 || j >= 1e4 ? (j < 0 ? "-": "+") + H(6, j < 0 ? -j: j) : H(4, j)) + "-" + H(2, k + 1) + "-" + H(2, m) + "T" + H(2, r) + ":" + H(2, t) + ":" + H(2, u) + "." + H(3, v) + "Z"
- } else h = null;
- if (c && (h = c.call(b, a, h)), null === h) return "null";
- if (i = s.call(h), i == A) return "" + h;
- if (i == x) return h > -1 / 0 && h < 1 / 0 ? "" + h: "null";
- if (i == y) return J("" + h);
- if ("object" == typeof h) {
- for (G = g.length; G--;) if (g[G] === h) throw l();
- if (g.push(h), B = [], I = f, f += e, i == z) {
- for (F = 0, G = h.length; F < G; F++) D = K(F, h, c, d, e, f, g),
- B.push(D === q ? "null": D);
- L = B.length ? e ? "[\n" + f + B.join(",\n" + f) + "\n" + I + "]": "[" + B.join(",") + "]": "[]"
- } else p(d || h,
- function(a) {
- var b = K(a, h, c, d, e, f, g);
- b !== q && B.push(J(a) + ":" + (e ? " ": "") + b)
- }),
- L = B.length ? e ? "{\n" + f + B.join(",\n" + f) + "\n" + I + "}": "{" + B.join(",") + "}": "{}";
- return g.pop(),
- L
- }
- };
- b.stringify = function(a, b, c) {
- var d, e, f, h;
- if (g[typeof b] && b) if ((h = s.call(b)) == v) e = b;
- else if (h == z) {
- f = {};
- for (var i, j = 0,
- k = b.length; j < k; i = b[j++], h = s.call(i), (h == y || h == x) && (f[i] = 1));
- }
- if (c) if ((h = s.call(c)) == x) {
- if ((c -= c % 1) > 0) for (d = "", c > 10 && (c = 10); d.length < c; d += " ");
- } else h == y && (d = c.length <= 10 ? c: c.slice(0, 10));
- return K("", (i = {},
- i[""] = a, i), e, f, d, "", [])
- }
- }
- if (!c("json-parse")) {
- var L, M, N = f.fromCharCode,
- O = {
- 92 : "\\",
- 34 : '"',
- 47 : "/",
- 98 : "\b",
- 116 : "\t",
- 110 : "\n",
- 102 : "\f",
- 114 : "\r"
- },
- P = function() {
- throw L = M = null,
- k()
- },
- Q = function() {
- for (var a, b, c, d, e, f = M,
- g = f.length; L < g;) switch (e = f.charCodeAt(L)) {
- case 9:
- case 10:
- case 13:
- case 32:
- L++;
- break;
- case 123:
- case 125:
- case 91:
- case 93:
- case 58:
- case 44:
- return a = B ? f.charAt(L) : f[L],
- L++,
- a;
- case 34:
- for (a = "@", L++; L < g;) if (e = f.charCodeAt(L), e < 32) P();
- else if (92 == e) switch (e = f.charCodeAt(++L)) {
- case 92:
- case 34:
- case 47:
- case 98:
- case 116:
- case 110:
- case 102:
- case 114:
- a += O[e],
- L++;
- break;
- case 117:
- for (b = ++L, c = L + 4; L < c; L++) e = f.charCodeAt(L),
- e >= 48 && e <= 57 || e >= 97 && e <= 102 || e >= 65 && e <= 70 || P();
- a += N("0x" + f.slice(b, L));
- break;
- default:
- P()
- } else {
- if (34 == e) break;
- for (e = f.charCodeAt(L), b = L; e >= 32 && 92 != e && 34 != e;) e = f.charCodeAt(++L);
- a += f.slice(b, L)
- }
- if (34 == f.charCodeAt(L)) return L++,
- a;
- P();
- default:
- if (b = L, 45 == e && (d = !0, e = f.charCodeAt(++L)), e >= 48 && e <= 57) {
- for (48 == e && (e = f.charCodeAt(L + 1), e >= 48 && e <= 57) && P(), d = !1; L < g && (e = f.charCodeAt(L), e >= 48 && e <= 57); L++);
- if (46 == f.charCodeAt(L)) {
- for (c = ++L; c < g && (e = f.charCodeAt(c), e >= 48 && e <= 57); c++);
- c == L && P(),
- L = c
- }
- if (e = f.charCodeAt(L), 101 == e || 69 == e) {
- for (e = f.charCodeAt(++L), 43 != e && 45 != e || L++, c = L; c < g && (e = f.charCodeAt(c), e >= 48 && e <= 57); c++);
- c == L && P(),
- L = c
- }
- return + f.slice(b, L)
- }
- if (d && P(), "true" == f.slice(L, L + 4)) return L += 4,
- !0;
- if ("false" == f.slice(L, L + 5)) return L += 5,
- !1;
- if ("null" == f.slice(L, L + 4)) return L += 4,
- null;
- P()
- }
- return "$"
- },
- R = function(a) {
- var b, c;
- if ("$" == a && P(), "string" == typeof a) {
- if ("@" == (B ? a.charAt(0) : a[0])) return a.slice(1);
- if ("[" == a) {
- for (b = []; a = Q(), "]" != a; c || (c = !0)) c && ("," == a ? (a = Q(), "]" == a && P()) : P()),
- "," == a && P(),
- b.push(R(a));
- return b
- }
- if ("{" == a) {
- for (b = {}; a = Q(), "}" != a; c || (c = !0)) c && ("," == a ? (a = Q(), "}" == a && P()) : P()),
- "," != a && "string" == typeof a && "@" == (B ? a.charAt(0) : a[0]) && ":" == Q() || P(),
- b[a.slice(1)] = R(Q());
- return b
- }
- P()
- }
- return a
- },
- S = function(a, b, c) {
- var d = T(a, b, c);
- d === q ? delete a[b] : a[b] = d
- },
- T = function(a, b, c) {
- var d, e = a[b];
- if ("object" == typeof e && e) if (s.call(e) == z) for (d = e.length; d--;) S(e, d, c);
- else p(e,
- function(a) {
- S(e, a, c)
- });
- return c.call(a, b, e)
- };
- b.parse = function(a, b) {
- var c, d;
- return L = 0,
- M = "" + a,
- c = R(Q()),
- "$" != Q() && P(),
- L = M = null,
- b && s.call(b) == v ? T((d = {},
- d[""] = c, d), "", b) : c
- }
- }
- }
- return b.runInContext = e,
- b
- }
- var f = "function" == typeof d && d.amd,
- g = {
- "function": !0,
- object: !0
- },
- h = g[typeof b] && b && !b.nodeType && b,
- i = g[typeof window] && window || this,
- j = h && g[typeof a] && a && !a.nodeType && "object" == typeof c && c;
- if (!j || j.global !== j && j.window !== j && j.self !== j || (i = j), h && !f) e(i, h);
- else {
- var k = i.JSON,
- l = i.JSON3,
- m = !1,
- n = e(i, i.JSON3 = {
- noConflict: function() {
- return m || (m = !0, i.JSON = k, i.JSON3 = l, k = l = null),
- n
- }
- });
- i.JSON = {
- parse: n.parse,
- stringify: n.stringify
- }
- }
- f && d(function() {
- return n
- })
- }).call(this)
- }).call(b, c(12)(a),
- function() {
- return this
- } ())
- },
- function(a, b) {
- a.exports = function(a) {
- return a.webpackPolyfill || (a.deprecate = function() {},
- a.paths = [], a.children = [], a.webpackPolyfill = 1),
- a
- }
- },
- function(a, b) {
- function c(a) {
- if (a) return d(a)
- }
- function d(a) {
- for (var b in c.prototype) a[b] = c.prototype[b];
- return a
- }
- a.exports = c,
- c.prototype.on = c.prototype.addEventListener = function(a, b) {
- return this._callbacks = this._callbacks || {},
- (this._callbacks[a] = this._callbacks[a] || []).push(b),
- this
- },
- c.prototype.once = function(a, b) {
- function c() {
- d.off(a, c),
- b.apply(this, arguments)
- }
- var d = this;
- return this._callbacks = this._callbacks || {},
- c.fn = b,
- this.on(a, c),
- this
- },
- c.prototype.off = c.prototype.removeListener = c.prototype.removeAllListeners = c.prototype.removeEventListener = function(a, b) {
- if (this._callbacks = this._callbacks || {},
- 0 == arguments.length) return this._callbacks = {},
- this;
- var c = this._callbacks[a];
- if (!c) return this;
- if (1 == arguments.length) return delete this._callbacks[a],
- this;
- for (var d, e = 0; e < c.length; e++) if (d = c[e], d === b || d.fn === b) {
- c.splice(e, 1);
- break
- }
- return this
- },
- c.prototype.emit = function(a) {
- this._callbacks = this._callbacks || {};
- var b = [].slice.call(arguments, 1),
- c = this._callbacks[a];
- if (c) {
- c = c.slice(0);
- for (var d = 0,
- e = c.length; d < e; ++d) c[d].apply(this, b)
- }
- return this
- },
- c.prototype.listeners = function(a) {
- return this._callbacks = this._callbacks || {},
- this._callbacks[a] || []
- },
- c.prototype.hasListeners = function(a) {
- return !! this.listeners(a).length
- }
- },
- function(a, b, c) { (function(a) {
- var d = c(15),
- e = c(16);
- b.deconstructPacket = function(a) {
- function b(a) {
- if (!a) return a;
- if (e(a)) {
- var f = {
- _placeholder: !0,
- num: c.length
- };
- return c.push(a),
- f
- }
- if (d(a)) {
- for (var g = new Array(a.length), h = 0; h < a.length; h++) g[h] = b(a[h]);
- return g
- }
- if ("object" == typeof a && !(a instanceof Date)) {
- var g = {};
- for (var i in a) g[i] = b(a[i]);
- return g
- }
- return a
- }
- var c = [],
- f = a.data,
- g = a;
- return g.data = b(f),
- g.attachments = c.length,
- {
- packet: g,
- buffers: c
- }
- },
- b.reconstructPacket = function(a, b) {
- function c(a) {
- if (a && a._placeholder) {
- var e = b[a.num];
- return e
- }
- if (d(a)) {
- for (var f = 0; f < a.length; f++) a[f] = c(a[f]);
- return a
- }
- if (a && "object" == typeof a) {
- for (var g in a) a[g] = c(a[g]);
- return a
- }
- return a
- }
- return a.data = c(a.data),
- a.attachments = void 0,
- a
- },
- b.removeBlobs = function(b, c) {
- function f(b, i, j) {
- if (!b) return b;
- if (a.Blob && b instanceof Blob || a.File && b instanceof File) {
- g++;
- var k = new FileReader;
- k.onload = function() {
- j ? j[i] = this.result: h = this.result,
- --g || c(h)
- },
- k.readAsArrayBuffer(b)
- } else if (d(b)) for (var l = 0; l < b.length; l++) f(b[l], l, b);
- else if (b && "object" == typeof b && !e(b)) for (var m in b) f(b[m], m, b)
- }
- var g = 0,
- h = b;
- f(h),
- g || c(h)
- }
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b) {
- a.exports = Array.isArray ||
- function(a) {
- return "[object Array]" == Object.prototype.toString.call(a)
- }
- },
- function(a, b) { (function(b) {
- function c(a) {
- return b.Buffer && b.Buffer.isBuffer(a) || b.ArrayBuffer && a instanceof ArrayBuffer
- }
- a.exports = c
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b, c) {
- "use strict";
- function d(a, b) {
- return this instanceof d ? (a && "object" === ("undefined" == typeof a ? "undefined": e(a)) && (b = a, a = void 0), b = b || {},
- b.path = b.path || "/socket.io", this.nsps = {},
- this.subs = [], this.opts = b, this.reconnection(b.reconnection !== !1), this.reconnectionAttempts(b.reconnectionAttempts || 1 / 0), this.reconnectionDelay(b.reconnectionDelay || 1e3), this.reconnectionDelayMax(b.reconnectionDelayMax || 5e3), this.randomizationFactor(b.randomizationFactor || .5), this.backoff = new n({
- min: this.reconnectionDelay(),
- max: this.reconnectionDelayMax(),
- jitter: this.randomizationFactor()
- }), this.timeout(null == b.timeout ? 2e4: b.timeout), this.readyState = "closed", this.uri = a, this.connecting = [], this.lastPing = null, this.encoding = !1, this.packetBuffer = [], this.encoder = new i.Encoder, this.decoder = new i.Decoder, this.autoConnect = b.autoConnect !== !1, void(this.autoConnect && this.open())) : new d(a, b)
- }
- var e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
- function(a) {
- return typeof a
- }: function(a) {
- return a && "function" == typeof Symbol && a.constructor === Symbol && a !== Symbol.prototype ? "symbol": typeof a
- },
- f = c(18),
- g = c(44),
- h = c(35),
- i = c(7),
- j = c(46),
- k = c(47),
- l = c(3)("socket.io-client:manager"),
- m = c(42),
- n = c(48),
- o = Object.prototype.hasOwnProperty;
- a.exports = d,
- d.prototype.emitAll = function() {
- this.emit.apply(this, arguments);
- for (var a in this.nsps) o.call(this.nsps, a) && this.nsps[a].emit.apply(this.nsps[a], arguments)
- },
- d.prototype.updateSocketIds = function() {
- for (var a in this.nsps) o.call(this.nsps, a) && (this.nsps[a].id = this.engine.id)
- },
- h(d.prototype),
- d.prototype.reconnection = function(a) {
- return arguments.length ? (this._reconnection = !!a, this) : this._reconnection
- },
- d.prototype.reconnectionAttempts = function(a) {
- return arguments.length ? (this._reconnectionAttempts = a, this) : this._reconnectionAttempts
- },
- d.prototype.reconnectionDelay = function(a) {
- return arguments.length ? (this._reconnectionDelay = a, this.backoff && this.backoff.setMin(a), this) : this._reconnectionDelay
- },
- d.prototype.randomizationFactor = function(a) {
- return arguments.length ? (this._randomizationFactor = a, this.backoff && this.backoff.setJitter(a), this) : this._randomizationFactor
- },
- d.prototype.reconnectionDelayMax = function(a) {
- return arguments.length ? (this._reconnectionDelayMax = a, this.backoff && this.backoff.setMax(a), this) : this._reconnectionDelayMax
- },
- d.prototype.timeout = function(a) {
- return arguments.length ? (this._timeout = a, this) : this._timeout
- },
- d.prototype.maybeReconnectOnOpen = function() { ! this.reconnecting && this._reconnection && 0 === this.backoff.attempts && this.reconnect()
- },
- d.prototype.open = d.prototype.connect = function(a, b) {
- if (l("readyState %s", this.readyState), ~this.readyState.indexOf("open")) return this;
- l("opening %s", this.uri),
- this.engine = f(this.uri, this.opts);
- var c = this.engine,
- d = this;
- this.readyState = "opening",
- this.skipReconnect = !1;
- var e = j(c, "open",
- function() {
- d.onopen(),
- a && a()
- }),
- g = j(c, "error",
- function(b) {
- if (l("connect_error"), d.cleanup(), d.readyState = "closed", d.emitAll("connect_error", b), a) {
- var c = new Error("Connection error");
- c.data = b,
- a(c)
- } else d.maybeReconnectOnOpen()
- });
- if (!1 !== this._timeout) {
- var h = this._timeout;
- l("connect attempt will timeout after %d", h);
- var i = setTimeout(function() {
- l("connect attempt timed out after %d", h),
- e.destroy(),
- c.close(),
- c.emit("error", "timeout"),
- d.emitAll("connect_timeout", h)
- },
- h);
- this.subs.push({
- destroy: function() {
- clearTimeout(i)
- }
- })
- }
- return this.subs.push(e),
- this.subs.push(g),
- this
- },
- d.prototype.onopen = function() {
- l("open"),
- this.cleanup(),
- this.readyState = "open",
- this.emit("open");
- var a = this.engine;
- this.subs.push(j(a, "data", k(this, "ondata"))),
- this.subs.push(j(a, "ping", k(this, "onping"))),
- this.subs.push(j(a, "pong", k(this, "onpong"))),
- this.subs.push(j(a, "error", k(this, "onerror"))),
- this.subs.push(j(a, "close", k(this, "onclose"))),
- this.subs.push(j(this.decoder, "decoded", k(this, "ondecoded")))
- },
- d.prototype.onping = function() {
- this.lastPing = new Date,
- this.emitAll("ping")
- },
- d.prototype.onpong = function() {
- this.emitAll("pong", new Date - this.lastPing)
- },
- d.prototype.ondata = function(a) {
- this.decoder.add(a)
- },
- d.prototype.ondecoded = function(a) {
- this.emit("packet", a)
- },
- d.prototype.onerror = function(a) {
- l("error", a),
- this.emitAll("error", a)
- },
- d.prototype.socket = function(a, b) {
- function c() {~m(e.connecting, d) || e.connecting.push(d)
- }
- var d = this.nsps[a];
- if (!d) {
- d = new g(this, a, b),
- this.nsps[a] = d;
- var e = this;
- d.on("connecting", c),
- d.on("connect",
- function() {
- d.id = e.engine.id
- }),
- this.autoConnect && c()
- }
- return d
- },
- d.prototype.destroy = function(a) {
- var b = m(this.connecting, a);~b && this.connecting.splice(b, 1),
- this.connecting.length || this.close()
- },
- d.prototype.packet = function(a) {
- l("writing packet %j", a);
- var b = this;
- a.query && 0 === a.type && (a.nsp += "?" + a.query),
- b.encoding ? b.packetBuffer.push(a) : (b.encoding = !0, this.encoder.encode(a,
- function(c) {
- for (var d = 0; d < c.length; d++) b.engine.write(c[d], a.options);
- b.encoding = !1,
- b.processPacketQueue()
- }))
- },
- d.prototype.processPacketQueue = function() {
- if (this.packetBuffer.length > 0 && !this.encoding) {
- var a = this.packetBuffer.shift();
- this.packet(a)
- }
- },
- d.prototype.cleanup = function() {
- l("cleanup");
- for (var a = this.subs.length,
- b = 0; b < a; b++) {
- var c = this.subs.shift();
- c.destroy()
- }
- this.packetBuffer = [],
- this.encoding = !1,
- this.lastPing = null,
- this.decoder.destroy()
- },
- d.prototype.close = d.prototype.disconnect = function() {
- l("disconnect"),
- this.skipReconnect = !0,
- this.reconnecting = !1,
- "opening" === this.readyState && this.cleanup(),
- this.backoff.reset(),
- this.readyState = "closed",
- this.engine && this.engine.close()
- },
- d.prototype.onclose = function(a) {
- l("onclose"),
- this.cleanup(),
- this.backoff.reset(),
- this.readyState = "closed",
- this.emit("close", a),
- this._reconnection && !this.skipReconnect && this.reconnect()
- },
- d.prototype.reconnect = function() {
- if (this.reconnecting || this.skipReconnect) return this;
- var a = this;
- if (this.backoff.attempts >= this._reconnectionAttempts) l("reconnect failed"),
- this.backoff.reset(),
- this.emitAll("reconnect_failed"),
- this.reconnecting = !1;
- else {
- var b = this.backoff.duration();
- l("will wait %dms before reconnect attempt", b),
- this.reconnecting = !0;
- var c = setTimeout(function() {
- a.skipReconnect || (l("attempting reconnect"), a.emitAll("reconnect_attempt", a.backoff.attempts), a.emitAll("reconnecting", a.backoff.attempts), a.skipReconnect || a.open(function(b) {
- b ? (l("reconnect attempt error"), a.reconnecting = !1, a.reconnect(), a.emitAll("reconnect_error", b.data)) : (l("reconnect success"), a.onreconnect())
- }))
- },
- b);
- this.subs.push({
- destroy: function() {
- clearTimeout(c)
- }
- })
- }
- },
- d.prototype.onreconnect = function() {
- var a = this.backoff.attempts;
- this.reconnecting = !1,
- this.backoff.reset(),
- this.updateSocketIds(),
- this.emitAll("reconnect", a)
- }
- },
- function(a, b, c) {
- a.exports = c(19)
- },
- function(a, b, c) {
- a.exports = c(20),
- a.exports.parser = c(27)
- },
- function(a, b, c) { (function(b) {
- function d(a, c) {
- if (! (this instanceof d)) return new d(a, c);
- c = c || {},
- a && "object" == typeof a && (c = a, a = null),
- a ? (a = k(a), c.hostname = a.host, c.secure = "https" === a.protocol || "wss" === a.protocol, c.port = a.port, a.query && (c.query = a.query)) : c.host && (c.hostname = k(c.host).host),
- this.secure = null != c.secure ? c.secure: b.location && "https:" === location.protocol,
- c.hostname && !c.port && (c.port = this.secure ? "443": "80"),
- this.agent = c.agent || !1,
- this.hostname = c.hostname || (b.location ? location.hostname: "localhost"),
- this.port = c.port || (b.location && location.port ? location.port: this.secure ? 443 : 80),
- this.query = c.query || {},
- "string" == typeof this.query && (this.query = m.decode(this.query)),
- this.upgrade = !1 !== c.upgrade,
- this.path = (c.path || "/engine.io").replace(/\/$/, "") + "/",
- this.forceJSONP = !!c.forceJSONP,
- this.jsonp = !1 !== c.jsonp,
- this.forceBase64 = !!c.forceBase64,
- this.enablesXDR = !!c.enablesXDR,
- this.timestampParam = c.timestampParam || "t",
- this.timestampRequests = c.timestampRequests,
- this.transports = c.transports || ["polling", "websocket"],
- this.readyState = "",
- this.writeBuffer = [],
- this.prevBufferLen = 0,
- this.policyPort = c.policyPort || 843,
- this.rememberUpgrade = c.rememberUpgrade || !1,
- this.binaryType = null,
- this.onlyBinaryUpgrades = c.onlyBinaryUpgrades,
- this.perMessageDeflate = !1 !== c.perMessageDeflate && (c.perMessageDeflate || {}),
- !0 === this.perMessageDeflate && (this.perMessageDeflate = {}),
- this.perMessageDeflate && null == this.perMessageDeflate.threshold && (this.perMessageDeflate.threshold = 1024),
- this.pfx = c.pfx || null,
- this.key = c.key || null,
- this.passphrase = c.passphrase || null,
- this.cert = c.cert || null,
- this.ca = c.ca || null,
- this.ciphers = c.ciphers || null,
- this.rejectUnauthorized = void 0 === c.rejectUnauthorized ? null: c.rejectUnauthorized,
- this.forceNode = !!c.forceNode;
- var e = "object" == typeof b && b;
- e.global === e && (c.extraHeaders && Object.keys(c.extraHeaders).length > 0 && (this.extraHeaders = c.extraHeaders), c.localAddress && (this.localAddress = c.localAddress)),
- this.id = null,
- this.upgrades = null,
- this.pingInterval = null,
- this.pingTimeout = null,
- this.pingIntervalTimer = null,
- this.pingTimeoutTimer = null,
- this.open()
- }
- function e(a) {
- var b = {};
- for (var c in a) a.hasOwnProperty(c) && (b[c] = a[c]);
- return b
- }
- var f = c(21),
- g = c(35),
- h = c(3)("engine.io-client:socket"),
- i = c(42),
- j = c(27),
- k = c(2),
- l = c(43),
- m = c(36);
- a.exports = d,
- d.priorWebsocketSuccess = !1,
- g(d.prototype),
- d.protocol = j.protocol,
- d.Socket = d,
- d.Transport = c(26),
- d.transports = c(21),
- d.parser = c(27),
- d.prototype.createTransport = function(a) {
- h('creating transport "%s"', a);
- var b = e(this.query);
- b.EIO = j.protocol,
- b.transport = a,
- this.id && (b.sid = this.id);
- var c = new f[a]({
- agent: this.agent,
- hostname: this.hostname,
- port: this.port,
- secure: this.secure,
- path: this.path,
- query: b,
- forceJSONP: this.forceJSONP,
- jsonp: this.jsonp,
- forceBase64: this.forceBase64,
- enablesXDR: this.enablesXDR,
- timestampRequests: this.timestampRequests,
- timestampParam: this.timestampParam,
- policyPort: this.policyPort,
- socket: this,
- pfx: this.pfx,
- key: this.key,
- passphrase: this.passphrase,
- cert: this.cert,
- ca: this.ca,
- ciphers: this.ciphers,
- rejectUnauthorized: this.rejectUnauthorized,
- perMessageDeflate: this.perMessageDeflate,
- extraHeaders: this.extraHeaders,
- forceNode: this.forceNode,
- localAddress: this.localAddress
- });
- return c
- },
- d.prototype.open = function() {
- var a;
- if (this.rememberUpgrade && d.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1) a = "websocket";
- else {
- if (0 === this.transports.length) {
- var b = this;
- return void setTimeout(function() {
- b.emit("error", "No transports available")
- },
- 0)
- }
- a = this.transports[0]
- }
- this.readyState = "opening";
- try {
- a = this.createTransport(a)
- } catch(c) {
- return this.transports.shift(),
- void this.open()
- }
- a.open(),
- this.setTransport(a)
- },
- d.prototype.setTransport = function(a) {
- h("setting transport %s", a.name);
- var b = this;
- this.transport && (h("clearing existing transport %s", this.transport.name), this.transport.removeAllListeners()),
- this.transport = a,
- a.on("drain",
- function() {
- b.onDrain()
- }).on("packet",
- function(a) {
- b.onPacket(a)
- }).on("error",
- function(a) {
- b.onError(a)
- }).on("close",
- function() {
- b.onClose("transport close")
- })
- },
- d.prototype.probe = function(a) {
- function b() {
- if (m.onlyBinaryUpgrades) {
- var b = !this.supportsBinary && m.transport.supportsBinary;
- l = l || b
- }
- l || (h('probe transport "%s" opened', a), k.send([{
- type: "ping",
- data: "probe"
- }]), k.once("packet",
- function(b) {
- if (!l) if ("pong" === b.type && "probe" === b.data) {
- if (h('probe transport "%s" pong', a), m.upgrading = !0, m.emit("upgrading", k), !k) return;
- d.priorWebsocketSuccess = "websocket" === k.name,
- h('pausing current transport "%s"', m.transport.name),
- m.transport.pause(function() {
- l || "closed" !== m.readyState && (h("changing transport and sending upgrade packet"), j(), m.setTransport(k), k.send([{
- type: "upgrade"
- }]), m.emit("upgrade", k), k = null, m.upgrading = !1, m.flush())
- })
- } else {
- h('probe transport "%s" failed', a);
- var c = new Error("probe error");
- c.transport = k.name,
- m.emit("upgradeError", c)
- }
- }))
- }
- function c() {
- l || (l = !0, j(), k.close(), k = null)
- }
- function e(b) {
- var d = new Error("probe error: " + b);
- d.transport = k.name,
- c(),
- h('probe transport "%s" failed because of error: %s', a, b),
- m.emit("upgradeError", d)
- }
- function f() {
- e("transport closed")
- }
- function g() {
- e("socket closed")
- }
- function i(a) {
- k && a.name !== k.name && (h('"%s" works - aborting "%s"', a.name, k.name), c())
- }
- function j() {
- k.removeListener("open", b),
- k.removeListener("error", e),
- k.removeListener("close", f),
- m.removeListener("close", g),
- m.removeListener("upgrading", i)
- }
- h('probing transport "%s"', a);
- var k = this.createTransport(a, {
- probe: 1
- }),
- l = !1,
- m = this;
- d.priorWebsocketSuccess = !1,
- k.once("open", b),
- k.once("error", e),
- k.once("close", f),
- this.once("close", g),
- this.once("upgrading", i),
- k.open()
- },
- d.prototype.onOpen = function() {
- if (h("socket open"), this.readyState = "open", d.priorWebsocketSuccess = "websocket" === this.transport.name, this.emit("open"), this.flush(), "open" === this.readyState && this.upgrade && this.transport.pause) {
- h("starting upgrade probes");
- for (var a = 0,
- b = this.upgrades.length; a < b; a++) this.probe(this.upgrades[a])
- }
- },
- d.prototype.onPacket = function(a) {
- if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) switch (h('socket receive: type "%s", data "%s"', a.type, a.data), this.emit("packet", a), this.emit("heartbeat"), a.type) {
- case "open":
- this.onHandshake(l(a.data));
- break;
- case "pong":
- this.setPing(),
- this.emit("pong");
- break;
- case "error":
- var b = new Error("server error");
- b.code = a.data,
- this.onError(b);
- break;
- case "message":
- this.emit("data", a.data),
- this.emit("message", a.data)
- } else h('packet received with socket readyState "%s"', this.readyState)
- },
- d.prototype.onHandshake = function(a) {
- this.emit("handshake", a),
- this.id = a.sid,
- this.transport.query.sid = a.sid,
- this.upgrades = this.filterUpgrades(a.upgrades),
- this.pingInterval = a.pingInterval,
- this.pingTimeout = a.pingTimeout,
- this.onOpen(),
- "closed" !== this.readyState && (this.setPing(), this.removeListener("heartbeat", this.onHeartbeat), this.on("heartbeat", this.onHeartbeat))
- },
- d.prototype.onHeartbeat = function(a) {
- clearTimeout(this.pingTimeoutTimer);
- var b = this;
- b.pingTimeoutTimer = setTimeout(function() {
- "closed" !== b.readyState && b.onClose("ping timeout")
- },
- a || b.pingInterval + b.pingTimeout)
- },
- d.prototype.setPing = function() {
- var a = this;
- clearTimeout(a.pingIntervalTimer),
- a.pingIntervalTimer = setTimeout(function() {
- h("writing ping packet - expecting pong within %sms", a.pingTimeout),
- a.ping(),
- a.onHeartbeat(a.pingTimeout)
- },
- a.pingInterval)
- },
- d.prototype.ping = function() {
- var a = this;
- this.sendPacket("ping",
- function() {
- a.emit("ping")
- })
- },
- d.prototype.onDrain = function() {
- this.writeBuffer.splice(0, this.prevBufferLen),
- this.prevBufferLen = 0,
- 0 === this.writeBuffer.length ? this.emit("drain") : this.flush()
- },
- d.prototype.flush = function() {
- "closed" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length && (h("flushing %d packets in socket", this.writeBuffer.length), this.transport.send(this.writeBuffer), this.prevBufferLen = this.writeBuffer.length, this.emit("flush"))
- },
- d.prototype.write = d.prototype.send = function(a, b, c) {
- return this.sendPacket("message", a, b, c),
- this
- },
- d.prototype.sendPacket = function(a, b, c, d) {
- if ("function" == typeof b && (d = b, b = void 0), "function" == typeof c && (d = c, c = null), "closing" !== this.readyState && "closed" !== this.readyState) {
- c = c || {},
- c.compress = !1 !== c.compress;
- var e = {
- type: a,
- data: b,
- options: c
- };
- this.emit("packetCreate", e),
- this.writeBuffer.push(e),
- d && this.once("flush", d),
- this.flush()
- }
- },
- d.prototype.close = function() {
- function a() {
- d.onClose("forced close"),
- h("socket closing - telling transport to close"),
- d.transport.close()
- }
- function b() {
- d.removeListener("upgrade", b),
- d.removeListener("upgradeError", b),
- a()
- }
- function c() {
- d.once("upgrade", b),
- d.once("upgradeError", b)
- }
- if ("opening" === this.readyState || "open" === this.readyState) {
- this.readyState = "closing";
- var d = this;
- this.writeBuffer.length ? this.once("drain",
- function() {
- this.upgrading ? c() : a()
- }) : this.upgrading ? c() : a()
- }
- return this
- },
- d.prototype.onError = function(a) {
- h("socket error %j", a),
- d.priorWebsocketSuccess = !1,
- this.emit("error", a),
- this.onClose("transport error", a)
- },
- d.prototype.onClose = function(a, b) {
- if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState) {
- h('socket close with reason: "%s"', a);
- var c = this;
- clearTimeout(this.pingIntervalTimer),
- clearTimeout(this.pingTimeoutTimer),
- this.transport.removeAllListeners("close"),
- this.transport.close(),
- this.transport.removeAllListeners(),
- this.readyState = "closed",
- this.id = null,
- this.emit("close", a, b),
- c.writeBuffer = [],
- c.prevBufferLen = 0
- }
- },
- d.prototype.filterUpgrades = function(a) {
- for (var b = [], c = 0, d = a.length; c < d; c++)~i(this.transports, a[c]) && b.push(a[c]);
- return b
- }
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b, c) { (function(a) {
- function d(b) {
- var c, d = !1,
- h = !1,
- i = !1 !== b.jsonp;
- if (a.location) {
- var j = "https:" === location.protocol,
- k = location.port;
- k || (k = j ? 443 : 80),
- d = b.hostname !== location.hostname || k !== b.port,
- h = b.secure !== j
- }
- if (b.xdomain = d, b.xscheme = h, c = new e(b), "open" in c && !b.forceJSONP) return new f(b);
- if (!i) throw new Error("JSONP disabled");
- return new g(b)
- }
- var e = c(22),
- f = c(24),
- g = c(39),
- h = c(40);
- b.polling = d,
- b.websocket = h
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b, c) { (function(b) {
- var d = c(23);
- a.exports = function(a) {
- var c = a.xdomain,
- e = a.xscheme,
- f = a.enablesXDR;
- try {
- if ("undefined" != typeof XMLHttpRequest && (!c || d)) return new XMLHttpRequest
- } catch(g) {}
- try {
- if ("undefined" != typeof XDomainRequest && !e && f) return new XDomainRequest
- } catch(g) {}
- if (!c) try {
- return new(b[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")
- } catch(g) {}
- }
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b) {
- try {
- a.exports = "undefined" != typeof XMLHttpRequest && "withCredentials" in new XMLHttpRequest
- } catch(c) {
- a.exports = !1
- }
- },
- function(a, b, c) { (function(b) {
- function d() {}
- function e(a) {
- if (i.call(this, a), this.requestTimeout = a.requestTimeout, b.location) {
- var c = "https:" === location.protocol,
- d = location.port;
- d || (d = c ? 443 : 80),
- this.xd = a.hostname !== b.location.hostname || d !== a.port,
- this.xs = a.secure !== c
- } else this.extraHeaders = a.extraHeaders
- }
- function f(a) {
- this.method = a.method || "GET",
- this.uri = a.uri,
- this.xd = !!a.xd,
- this.xs = !!a.xs,
- this.async = !1 !== a.async,
- this.data = void 0 !== a.data ? a.data: null,
- this.agent = a.agent,
- this.isBinary = a.isBinary,
- this.supportsBinary = a.supportsBinary,
- this.enablesXDR = a.enablesXDR,
- this.requestTimeout = a.requestTimeout,
- this.pfx = a.pfx,
- this.key = a.key,
- this.passphrase = a.passphrase,
- this.cert = a.cert,
- this.ca = a.ca,
- this.ciphers = a.ciphers,
- this.rejectUnauthorized = a.rejectUnauthorized,
- this.extraHeaders = a.extraHeaders,
- this.create()
- }
- function g() {
- for (var a in f.requests) f.requests.hasOwnProperty(a) && f.requests[a].abort()
- }
- var h = c(22),
- i = c(25),
- j = c(35),
- k = c(37),
- l = c(3)("engine.io-client:polling-xhr");
- a.exports = e,
- a.exports.Request = f,
- k(e, i),
- e.prototype.supportsBinary = !0,
- e.prototype.request = function(a) {
- return a = a || {},
- a.uri = this.uri(),
- a.xd = this.xd,
- a.xs = this.xs,
- a.agent = this.agent || !1,
- a.supportsBinary = this.supportsBinary,
- a.enablesXDR = this.enablesXDR,
- a.pfx = this.pfx,
- a.key = this.key,
- a.passphrase = this.passphrase,
- a.cert = this.cert,
- a.ca = this.ca,
- a.ciphers = this.ciphers,
- a.rejectUnauthorized = this.rejectUnauthorized,
- a.requestTimeout = this.requestTimeout,
- a.extraHeaders = this.extraHeaders,
- new f(a)
- },
- e.prototype.doWrite = function(a, b) {
- var c = "string" != typeof a && void 0 !== a,
- d = this.request({
- method: "POST",
- data: a,
- isBinary: c
- }),
- e = this;
- d.on("success", b),
- d.on("error",
- function(a) {
- e.onError("xhr post error", a)
- }),
- this.sendXhr = d
- },
- e.prototype.doPoll = function() {
- l("xhr poll");
- var a = this.request(),
- b = this;
- a.on("data",
- function(a) {
- b.onData(a)
- }),
- a.on("error",
- function(a) {
- b.onError("xhr poll error", a)
- }),
- this.pollXhr = a
- },
- j(f.prototype),
- f.prototype.create = function() {
- var a = {
- agent: this.agent,
- xdomain: this.xd,
- xscheme: this.xs,
- enablesXDR: this.enablesXDR
- };
- a.pfx = this.pfx,
- a.key = this.key,
- a.passphrase = this.passphrase,
- a.cert = this.cert,
- a.ca = this.ca,
- a.ciphers = this.ciphers,
- a.rejectUnauthorized = this.rejectUnauthorized;
- var c = this.xhr = new h(a),
- d = this;
- try {
- l("xhr open %s: %s", this.method, this.uri),
- c.open(this.method, this.uri, this.async);
- try {
- if (this.extraHeaders) {
- c.setDisableHeaderCheck(!0);
- for (var e in this.extraHeaders) this.extraHeaders.hasOwnProperty(e) && c.setRequestHeader(e, this.extraHeaders[e])
- }
- } catch(g) {}
- if (this.supportsBinary && (c.responseType = "arraybuffer"), "POST" === this.method) try {
- this.isBinary ? c.setRequestHeader("Content-type", "application/octet-stream") : c.setRequestHeader("Content-type", "text/plain;charset=UTF-8")
- } catch(g) {}
- try {
- c.setRequestHeader("Accept", "*/*")
- } catch(g) {}
- "withCredentials" in c && (c.withCredentials = !0),
- this.requestTimeout && (c.timeout = this.requestTimeout),
- this.hasXDR() ? (c.onload = function() {
- d.onLoad()
- },
- c.onerror = function() {
- d.onError(c.responseText)
- }) : c.onreadystatechange = function() {
- 4 === c.readyState && (200 === c.status || 1223 === c.status ? d.onLoad() : setTimeout(function() {
- d.onError(c.status)
- },
- 0))
- },
- l("xhr data %s", this.data),
- c.send(this.data)
- } catch(g) {
- return void setTimeout(function() {
- d.onError(g)
- },
- 0)
- }
- b.document && (this.index = f.requestsCount++, f.requests[this.index] = this)
- },
- f.prototype.onSuccess = function() {
- this.emit("success"),
- this.cleanup()
- },
- f.prototype.onData = function(a) {
- this.emit("data", a),
- this.onSuccess()
- },
- f.prototype.onError = function(a) {
- this.emit("error", a),
- this.cleanup(!0)
- },
- f.prototype.cleanup = function(a) {
- if ("undefined" != typeof this.xhr && null !== this.xhr) {
- if (this.hasXDR() ? this.xhr.onload = this.xhr.onerror = d: this.xhr.onreadystatechange = d, a) try {
- this.xhr.abort()
- } catch(c) {}
- b.document && delete f.requests[this.index],
- this.xhr = null
- }
- },
- f.prototype.onLoad = function() {
- var a;
- try {
- var b;
- try {
- b = this.xhr.getResponseHeader("Content-Type").split(";")[0]
- } catch(c) {}
- if ("application/octet-stream" === b) a = this.xhr.response || this.xhr.responseText;
- else if (this.supportsBinary) try {
- a = String.fromCharCode.apply(null, new Uint8Array(this.xhr.response))
- } catch(c) {
- for (var d = new Uint8Array(this.xhr.response), e = [], f = 0, g = d.length; f < g; f++) e.push(d[f]);
- a = String.fromCharCode.apply(null, e)
- } else a = this.xhr.responseText
- } catch(c) {
- this.onError(c)
- }
- null != a && this.onData(a)
- },
- f.prototype.hasXDR = function() {
- return "undefined" != typeof b.XDomainRequest && !this.xs && this.enablesXDR
- },
- f.prototype.abort = function() {
- this.cleanup()
- },
- f.requestsCount = 0,
- f.requests = {},
- b.document && (b.attachEvent ? b.attachEvent("onunload", g) : b.addEventListener && b.addEventListener("beforeunload", g, !1))
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b, c) {
- function d(a) {
- var b = a && a.forceBase64;
- k && !b || (this.supportsBinary = !1),
- e.call(this, a)
- }
- var e = c(26),
- f = c(36),
- g = c(27),
- h = c(37),
- i = c(38),
- j = c(3)("engine.io-client:polling");
- a.exports = d;
- var k = function() {
- var a = c(22),
- b = new a({
- xdomain: !1
- });
- return null != b.responseType
- } ();
- h(d, e),
- d.prototype.name = "polling",
- d.prototype.doOpen = function() {
- this.poll()
- },
- d.prototype.pause = function(a) {
- function b() {
- j("paused"),
- c.readyState = "paused",
- a()
- }
- var c = this;
- if (this.readyState = "pausing", this.polling || !this.writable) {
- var d = 0;
- this.polling && (j("we are currently polling - waiting to pause"), d++, this.once("pollComplete",
- function() {
- j("pre-pause polling complete"),
- --d || b()
- })),
- this.writable || (j("we are currently writing - waiting to pause"), d++, this.once("drain",
- function() {
- j("pre-pause writing complete"),
- --d || b()
- }))
- } else b()
- },
- d.prototype.poll = function() {
- j("polling"),
- this.polling = !0,
- this.doPoll(),
- this.emit("poll")
- },
- d.prototype.onData = function(a) {
- var b = this;
- j("polling got data %s", a);
- var c = function(a, c, d) {
- return "opening" === b.readyState && b.onOpen(),
- "close" === a.type ? (b.onClose(), !1) : void b.onPacket(a)
- };
- g.decodePayload(a, this.socket.binaryType, c),
- "closed" !== this.readyState && (this.polling = !1, this.emit("pollComplete"), "open" === this.readyState ? this.poll() : j('ignoring poll - transport state "%s"', this.readyState))
- },
- d.prototype.doClose = function() {
- function a() {
- j("writing close packet"),
- b.write([{
- type: "close"
- }])
- }
- var b = this;
- "open" === this.readyState ? (j("transport open - closing"), a()) : (j("transport not open - deferring close"), this.once("open", a))
- },
- d.prototype.write = function(a) {
- var b = this;
- this.writable = !1;
- var c = function() {
- b.writable = !0,
- b.emit("drain")
- };
- g.encodePayload(a, this.supportsBinary,
- function(a) {
- b.doWrite(a, c)
- })
- },
- d.prototype.uri = function() {
- var a = this.query || {},
- b = this.secure ? "https": "http",
- c = ""; ! 1 !== this.timestampRequests && (a[this.timestampParam] = i()),
- this.supportsBinary || a.sid || (a.b64 = 1),
- a = f.encode(a),
- this.port && ("https" === b && 443 !== Number(this.port) || "http" === b && 80 !== Number(this.port)) && (c = ":" + this.port),
- a.length && (a = "?" + a);
- var d = this.hostname.indexOf(":") !== -1;
- return b + "://" + (d ? "[" + this.hostname + "]": this.hostname) + c + this.path + a
- }
- },
- function(a, b, c) {
- function d(a) {
- this.path = a.path,
- this.hostname = a.hostname,
- this.port = a.port,
- this.secure = a.secure,
- this.query = a.query,
- this.timestampParam = a.timestampParam,
- this.timestampRequests = a.timestampRequests,
- this.readyState = "",
- this.agent = a.agent || !1,
- this.socket = a.socket,
- this.enablesXDR = a.enablesXDR,
- this.pfx = a.pfx,
- this.key = a.key,
- this.passphrase = a.passphrase,
- this.cert = a.cert,
- this.ca = a.ca,
- this.ciphers = a.ciphers,
- this.rejectUnauthorized = a.rejectUnauthorized,
- this.forceNode = a.forceNode,
- this.extraHeaders = a.extraHeaders,
- this.localAddress = a.localAddress
- }
- var e = c(27),
- f = c(35);
- a.exports = d,
- f(d.prototype),
- d.prototype.onError = function(a, b) {
- var c = new Error(a);
- return c.type = "TransportError",
- c.description = b,
- this.emit("error", c),
- this
- },
- d.prototype.open = function() {
- return "closed" !== this.readyState && "" !== this.readyState || (this.readyState = "opening", this.doOpen()),
- this
- },
- d.prototype.close = function() {
- return "opening" !== this.readyState && "open" !== this.readyState || (this.doClose(), this.onClose()),
- this
- },
- d.prototype.send = function(a) {
- if ("open" !== this.readyState) throw new Error("Transport not open");
- this.write(a)
- },
- d.prototype.onOpen = function() {
- this.readyState = "open",
- this.writable = !0,
- this.emit("open")
- },
- d.prototype.onData = function(a) {
- var b = e.decodePacket(a, this.socket.binaryType);
- this.onPacket(b)
- },
- d.prototype.onPacket = function(a) {
- this.emit("packet", a)
- },
- d.prototype.onClose = function() {
- this.readyState = "closed",
- this.emit("close")
- }
- },
- function(a, b, c) { (function(a) {
- function d(a, c) {
- var d = "b" + b.packets[a.type] + a.data.data;
- return c(d)
- }
- function e(a, c, d) {
- if (!c) return b.encodeBase64Packet(a, d);
- var e = a.data,
- f = new Uint8Array(e),
- g = new Uint8Array(1 + e.byteLength);
- g[0] = s[a.type];
- for (var h = 0; h < f.length; h++) g[h + 1] = f[h];
- return d(g.buffer)
- }
- function f(a, c, d) {
- if (!c) return b.encodeBase64Packet(a, d);
- var e = new FileReader;
- return e.onload = function() {
- a.data = e.result,
- b.encodePacket(a, c, !0, d)
- },
- e.readAsArrayBuffer(a.data)
- }
- function g(a, c, d) {
- if (!c) return b.encodeBase64Packet(a, d);
- if (r) return f(a, c, d);
- var e = new Uint8Array(1);
- e[0] = s[a.type];
- var g = new v([e.buffer, a.data]);
- return d(g)
- }
- function h(a) {
- try {
- a = o.decode(a)
- } catch(b) {
- return ! 1
- }
- return a
- }
- function i(a, b, c) {
- for (var d = new Array(a.length), e = n(a.length, c), f = function(a, c, e) {
- b(c,
- function(b, c) {
- d[a] = c,
- e(b, d)
- })
- },
- g = 0; g < a.length; g++) f(g, a[g], e)
- }
- var j, k = c(28),
- l = c(29),
- m = c(30),
- n = c(31),
- o = c(32);
- a && a.ArrayBuffer && (j = c(33));
- var p = "undefined" != typeof navigator && /Android/i.test(navigator.userAgent),
- q = "undefined" != typeof navigator && /PhantomJS/i.test(navigator.userAgent),
- r = p || q;
- b.protocol = 3;
- var s = b.packets = {
- open: 0,
- close: 1,
- ping: 2,
- pong: 3,
- message: 4,
- upgrade: 5,
- noop: 6
- },
- t = k(s),
- u = {
- type: "error",
- data: "parser error"
- },
- v = c(34);
- b.encodePacket = function(b, c, f, h) {
- "function" == typeof c && (h = c, c = !1),
- "function" == typeof f && (h = f, f = null);
- var i = void 0 === b.data ? void 0 : b.data.buffer || b.data;
- if (a.ArrayBuffer && i instanceof ArrayBuffer) return e(b, c, h);
- if (v && i instanceof a.Blob) return g(b, c, h);
- if (i && i.base64) return d(b, h);
- var j = s[b.type];
- return void 0 !== b.data && (j += f ? o.encode(String(b.data)) : String(b.data)),
- h("" + j)
- },
- b.encodeBase64Packet = function(c, d) {
- var e = "b" + b.packets[c.type];
- if (v && c.data instanceof a.Blob) {
- var f = new FileReader;
- return f.onload = function() {
- var a = f.result.split(",")[1];
- d(e + a)
- },
- f.readAsDataURL(c.data)
- }
- var g;
- try {
- g = String.fromCharCode.apply(null, new Uint8Array(c.data))
- } catch(h) {
- for (var i = new Uint8Array(c.data), j = new Array(i.length), k = 0; k < i.length; k++) j[k] = i[k];
- g = String.fromCharCode.apply(null, j)
- }
- return e += a.btoa(g),
- d(e)
- },
- b.decodePacket = function(a, c, d) {
- if (void 0 === a) return u;
- if ("string" == typeof a) {
- if ("b" == a.charAt(0)) return b.decodeBase64Packet(a.substr(1), c);
- if (d && (a = h(a), a === !1)) return u;
- var e = a.charAt(0);
- return Number(e) == e && t[e] ? a.length > 1 ? {
- type: t[e],
- data: a.substring(1)
- }: {
- type: t[e]
- }: u
- }
- var f = new Uint8Array(a),
- e = f[0],
- g = m(a, 1);
- return v && "blob" === c && (g = new v([g])),
- {
- type: t[e],
- data: g
- }
- },
- b.decodeBase64Packet = function(a, b) {
- var c = t[a.charAt(0)];
- if (!j) return {
- type: c,
- data: {
- base64: !0,
- data: a.substr(1)
- }
- };
- var d = j.decode(a.substr(1));
- return "blob" === b && v && (d = new v([d])),
- {
- type: c,
- data: d
- }
- },
- b.encodePayload = function(a, c, d) {
- function e(a) {
- return a.length + ":" + a
- }
- function f(a, d) {
- b.encodePacket(a, !!g && c, !0,
- function(a) {
- d(null, e(a))
- })
- }
- "function" == typeof c && (d = c, c = null);
- var g = l(a);
- return c && g ? v && !r ? b.encodePayloadAsBlob(a, d) : b.encodePayloadAsArrayBuffer(a, d) : a.length ? void i(a, f,
- function(a, b) {
- return d(b.join(""))
- }) : d("0:")
- },
- b.decodePayload = function(a, c, d) {
- if ("string" != typeof a) return b.decodePayloadAsBinary(a, c, d);
- "function" == typeof c && (d = c, c = null);
- var e;
- if ("" == a) return d(u, 0, 1);
- for (var f, g, h = "",
- i = 0,
- j = a.length; i < j; i++) {
- var k = a.charAt(i);
- if (":" != k) h += k;
- else {
- if ("" == h || h != (f = Number(h))) return d(u, 0, 1);
- if (g = a.substr(i + 1, f), h != g.length) return d(u, 0, 1);
- if (g.length) {
- if (e = b.decodePacket(g, c, !0), u.type == e.type && u.data == e.data) return d(u, 0, 1);
- var l = d(e, i + f, j);
- if (!1 === l) return
- }
- i += f,
- h = ""
- }
- }
- return "" != h ? d(u, 0, 1) : void 0
- },
- b.encodePayloadAsArrayBuffer = function(a, c) {
- function d(a, c) {
- b.encodePacket(a, !0, !0,
- function(a) {
- return c(null, a)
- })
- }
- return a.length ? void i(a, d,
- function(a, b) {
- var d = b.reduce(function(a, b) {
- var c;
- return c = "string" == typeof b ? b.length: b.byteLength,
- a + c.toString().length + c + 2
- },
- 0),
- e = new Uint8Array(d),
- f = 0;
- return b.forEach(function(a) {
- var b = "string" == typeof a,
- c = a;
- if (b) {
- for (var d = new Uint8Array(a.length), g = 0; g < a.length; g++) d[g] = a.charCodeAt(g);
- c = d.buffer
- }
- b ? e[f++] = 0 : e[f++] = 1;
- for (var h = c.byteLength.toString(), g = 0; g < h.length; g++) e[f++] = parseInt(h[g]);
- e[f++] = 255;
- for (var d = new Uint8Array(c), g = 0; g < d.length; g++) e[f++] = d[g]
- }),
- c(e.buffer)
- }) : c(new ArrayBuffer(0))
- },
- b.encodePayloadAsBlob = function(a, c) {
- function d(a, c) {
- b.encodePacket(a, !0, !0,
- function(a) {
- var b = new Uint8Array(1);
- if (b[0] = 1, "string" == typeof a) {
- for (var d = new Uint8Array(a.length), e = 0; e < a.length; e++) d[e] = a.charCodeAt(e);
- a = d.buffer,
- b[0] = 0
- }
- for (var f = a instanceof ArrayBuffer ? a.byteLength: a.size, g = f.toString(), h = new Uint8Array(g.length + 1), e = 0; e < g.length; e++) h[e] = parseInt(g[e]);
- if (h[g.length] = 255, v) {
- var i = new v([b.buffer, h.buffer, a]);
- c(null, i)
- }
- })
- }
- i(a, d,
- function(a, b) {
- return c(new v(b))
- })
- },
- b.decodePayloadAsBinary = function(a, c, d) {
- "function" == typeof c && (d = c, c = null);
- for (var e = a,
- f = [], g = !1; e.byteLength > 0;) {
- for (var h = new Uint8Array(e), i = 0 === h[0], j = "", k = 1; 255 != h[k]; k++) {
- if (j.length > 310) {
- g = !0;
- break
- }
- j += h[k]
- }
- if (g) return d(u, 0, 1);
- e = m(e, 2 + j.length),
- j = parseInt(j);
- var l = m(e, 0, j);
- if (i) try {
- l = String.fromCharCode.apply(null, new Uint8Array(l))
- } catch(n) {
- var o = new Uint8Array(l);
- l = "";
- for (var k = 0; k < o.length; k++) l += String.fromCharCode(o[k])
- }
- f.push(l),
- e = m(e, j)
- }
- var p = f.length;
- f.forEach(function(a, e) {
- d(b.decodePacket(a, c, !0), e, p)
- })
- }
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b) {
- a.exports = Object.keys ||
- function(a) {
- var b = [],
- c = Object.prototype.hasOwnProperty;
- for (var d in a) c.call(a, d) && b.push(d);
- return b
- }
- },
- function(a, b, c) { (function(b) {
- function d(a) {
- function c(a) {
- if (!a) return ! 1;
- if (b.Buffer && b.Buffer.isBuffer && b.Buffer.isBuffer(a) || b.ArrayBuffer && a instanceof ArrayBuffer || b.Blob && a instanceof Blob || b.File && a instanceof File) return ! 0;
- if (e(a)) {
- for (var d = 0; d < a.length; d++) if (c(a[d])) return ! 0
- } else if (a && "object" == typeof a) {
- a.toJSON && "function" == typeof a.toJSON && (a = a.toJSON());
- for (var f in a) if (Object.prototype.hasOwnProperty.call(a, f) && c(a[f])) return ! 0
- }
- return ! 1
- }
- return c(a)
- }
- var e = c(15);
- a.exports = d
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b) {
- a.exports = function(a, b, c) {
- var d = a.byteLength;
- if (b = b || 0, c = c || d, a.slice) return a.slice(b, c);
- if (b < 0 && (b += d), c < 0 && (c += d), c > d && (c = d), b >= d || b >= c || 0 === d) return new ArrayBuffer(0);
- for (var e = new Uint8Array(a), f = new Uint8Array(c - b), g = b, h = 0; g < c; g++, h++) f[h] = e[g];
- return f.buffer
- }
- },
- function(a, b) {
- function c(a, b, c) {
- function e(a, d) {
- if (e.count <= 0) throw new Error("after called too many times"); --e.count,
- a ? (f = !0, b(a), b = c) : 0 !== e.count || f || b(null, d)
- }
- var f = !1;
- return c = c || d,
- e.count = a,
- 0 === a ? b() : e
- }
- function d() {}
- a.exports = c
- },
- function(a, b, c) {
- var d; (function(a, e) { !
- function(f) {
- function g(a) {
- for (var b, c, d = [], e = 0, f = a.length; e < f;) b = a.charCodeAt(e++),
- b >= 55296 && b <= 56319 && e < f ? (c = a.charCodeAt(e++), 56320 == (64512 & c) ? d.push(((1023 & b) << 10) + (1023 & c) + 65536) : (d.push(b), e--)) : d.push(b);
- return d
- }
- function h(a) {
- for (var b, c = a.length,
- d = -1,
- e = ""; ++d < c;) b = a[d],
- b > 65535 && (b -= 65536, e += t(b >>> 10 & 1023 | 55296), b = 56320 | 1023 & b),
- e += t(b);
- return e
- }
- function i(a, b) {
- return t(a >> b & 63 | 128)
- }
- function j(a) {
- if (0 == (4294967168 & a)) return t(a);
- var b = "";
- return 0 == (4294965248 & a) ? b = t(a >> 6 & 31 | 192) : 0 == (4294901760 & a) ? (b = t(a >> 12 & 15 | 224), b += i(a, 6)) : 0 == (4292870144 & a) && (b = t(a >> 18 & 7 | 240), b += i(a, 12), b += i(a, 6)),
- b += t(63 & a | 128)
- }
- function k(a) {
- for (var b, c = g(a), d = c.length, e = -1, f = ""; ++e < d;) b = c[e],
- f += j(b);
- return f
- }
- function l() {
- if (s >= r) throw Error("Invalid byte index");
- var a = 255 & q[s];
- if (s++, 128 == (192 & a)) return 63 & a;
- throw Error("Invalid continuation byte")
- }
- function m() {
- var a, b, c, d, e;
- if (s > r) throw Error("Invalid byte index");
- if (s == r) return ! 1;
- if (a = 255 & q[s], s++, 0 == (128 & a)) return a;
- if (192 == (224 & a)) {
- var b = l();
- if (e = (31 & a) << 6 | b, e >= 128) return e;
- throw Error("Invalid continuation byte")
- }
- if (224 == (240 & a)) {
- if (b = l(), c = l(), e = (15 & a) << 12 | b << 6 | c, e >= 2048) return e;
- throw Error("Invalid continuation byte")
- }
- if (240 == (248 & a) && (b = l(), c = l(), d = l(), e = (15 & a) << 18 | b << 12 | c << 6 | d, e >= 65536 && e <= 1114111)) return e;
- throw Error("Invalid WTF-8 detected")
- }
- function n(a) {
- q = g(a),
- r = q.length,
- s = 0;
- for (var b, c = []; (b = m()) !== !1;) c.push(b);
- return h(c)
- }
- var o = "object" == typeof b && b,
- p = ("object" == typeof a && a && a.exports == o && a, "object" == typeof e && e);
- p.global !== p && p.window !== p || (f = p);
- var q, r, s, t = String.fromCharCode,
- u = {
- version: "1.0.0",
- encode: k,
- decode: n
- };
- d = function() {
- return u
- }.call(b, c, b, a),
- !(void 0 !== d && (a.exports = d))
- } (this)
- }).call(b, c(12)(a),
- function() {
- return this
- } ())
- },
- function(a, b) { !
- function() {
- "use strict";
- for (var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
- c = new Uint8Array(256), d = 0; d < a.length; d++) c[a.charCodeAt(d)] = d;
- b.encode = function(b) {
- var c, d = new Uint8Array(b),
- e = d.length,
- f = "";
- for (c = 0; c < e; c += 3) f += a[d[c] >> 2],
- f += a[(3 & d[c]) << 4 | d[c + 1] >> 4],
- f += a[(15 & d[c + 1]) << 2 | d[c + 2] >> 6],
- f += a[63 & d[c + 2]];
- return e % 3 === 2 ? f = f.substring(0, f.length - 1) + "=": e % 3 === 1 && (f = f.substring(0, f.length - 2) + "=="),
- f
- },
- b.decode = function(a) {
- var b, d, e, f, g, h = .75 * a.length,
- i = a.length,
- j = 0;
- "=" === a[a.length - 1] && (h--, "=" === a[a.length - 2] && h--);
- var k = new ArrayBuffer(h),
- l = new Uint8Array(k);
- for (b = 0; b < i; b += 4) d = c[a.charCodeAt(b)],
- e = c[a.charCodeAt(b + 1)],
- f = c[a.charCodeAt(b + 2)],
- g = c[a.charCodeAt(b + 3)],
- l[j++] = d << 2 | e >> 4,
- l[j++] = (15 & e) << 4 | f >> 2,
- l[j++] = (3 & f) << 6 | 63 & g;
- return k
- }
- } ()
- },
- function(a, b) { (function(b) {
- function c(a) {
- for (var b = 0; b < a.length; b++) {
- var c = a[b];
- if (c.buffer instanceof ArrayBuffer) {
- var d = c.buffer;
- if (c.byteLength !== d.byteLength) {
- var e = new Uint8Array(c.byteLength);
- e.set(new Uint8Array(d, c.byteOffset, c.byteLength)),
- d = e.buffer
- }
- a[b] = d
- }
- }
- }
- function d(a, b) {
- b = b || {};
- var d = new f;
- c(a);
- for (var e = 0; e < a.length; e++) d.append(a[e]);
- return b.type ? d.getBlob(b.type) : d.getBlob()
- }
- function e(a, b) {
- return c(a),
- new Blob(a, b || {})
- }
- var f = b.BlobBuilder || b.WebKitBlobBuilder || b.MSBlobBuilder || b.MozBlobBuilder,
- g = function() {
- try {
- var a = new Blob(["hi"]);
- return 2 === a.size
- } catch(b) {
- return ! 1
- }
- } (),
- h = g &&
- function() {
- try {
- var a = new Blob([new Uint8Array([1, 2])]);
- return 2 === a.size
- } catch(b) {
- return ! 1
- }
- } (),
- i = f && f.prototype.append && f.prototype.getBlob;
- a.exports = function() {
- return g ? h ? b.Blob: e: i ? d: void 0
- } ()
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b, c) {
- function d(a) {
- if (a) return e(a)
- }
- function e(a) {
- for (var b in d.prototype) a[b] = d.prototype[b];
- return a
- }
- a.exports = d,
- d.prototype.on = d.prototype.addEventListener = function(a, b) {
- return this._callbacks = this._callbacks || {},
- (this._callbacks["$" + a] = this._callbacks["$" + a] || []).push(b),
- this
- },
- d.prototype.once = function(a, b) {
- function c() {
- this.off(a, c),
- b.apply(this, arguments)
- }
- return c.fn = b,
- this.on(a, c),
- this
- },
- d.prototype.off = d.prototype.removeListener = d.prototype.removeAllListeners = d.prototype.removeEventListener = function(a, b) {
- if (this._callbacks = this._callbacks || {},
- 0 == arguments.length) return this._callbacks = {},
- this;
- var c = this._callbacks["$" + a];
- if (!c) return this;
- if (1 == arguments.length) return delete this._callbacks["$" + a],
- this;
- for (var d, e = 0; e < c.length; e++) if (d = c[e], d === b || d.fn === b) {
- c.splice(e, 1);
- break
- }
- return this
- },
- d.prototype.emit = function(a) {
- this._callbacks = this._callbacks || {};
- var b = [].slice.call(arguments, 1),
- c = this._callbacks["$" + a];
- if (c) {
- c = c.slice(0);
- for (var d = 0,
- e = c.length; d < e; ++d) c[d].apply(this, b)
- }
- return this
- },
- d.prototype.listeners = function(a) {
- return this._callbacks = this._callbacks || {},
- this._callbacks["$" + a] || []
- },
- d.prototype.hasListeners = function(a) {
- return !! this.listeners(a).length
- }
- },
- function(a, b) {
- b.encode = function(a) {
- var b = "";
- for (var c in a) a.hasOwnProperty(c) && (b.length && (b += "&"), b += encodeURIComponent(c) + "=" + encodeURIComponent(a[c]));
- return b
- },
- b.decode = function(a) {
- for (var b = {},
- c = a.split("&"), d = 0, e = c.length; d < e; d++) {
- var f = c[d].split("=");
- b[decodeURIComponent(f[0])] = decodeURIComponent(f[1])
- }
- return b
- }
- },
- function(a, b) {
- a.exports = function(a, b) {
- var c = function() {};
- c.prototype = b.prototype,
- a.prototype = new c,
- a.prototype.constructor = a
- }
- },
- function(a, b) {
- "use strict";
- function c(a) {
- var b = "";
- do b = g[a % h] + b,
- a = Math.floor(a / h);
- while (a > 0);
- return b
- }
- function d(a) {
- var b = 0;
- for (k = 0; k < a.length; k++) b = b * h + i[a.charAt(k)];
- return b
- }
- function e() {
- var a = c( + new Date);
- return a !== f ? (j = 0, f = a) : a + "." + c(j++)
- }
- for (var f, g = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""), h = 64, i = {},
- j = 0, k = 0; k < h; k++) i[g[k]] = k;
- e.encode = c,
- e.decode = d,
- a.exports = e
- },
- function(a, b, c) { (function(b) {
- function d() {}
- function e(a) {
- f.call(this, a),
- this.query = this.query || {},
- h || (b.___eio || (b.___eio = []), h = b.___eio),
- this.index = h.length;
- var c = this;
- h.push(function(a) {
- c.onData(a)
- }),
- this.query.j = this.index,
- b.document && b.addEventListener && b.addEventListener("beforeunload",
- function() {
- c.script && (c.script.onerror = d)
- },
- !1)
- }
- var f = c(25),
- g = c(37);
- a.exports = e;
- var h, i = /\n/g,
- j = /\\n/g;
- g(e, f),
- e.prototype.supportsBinary = !1,
- e.prototype.doClose = function() {
- this.script && (this.script.parentNode.removeChild(this.script), this.script = null),
- this.form && (this.form.parentNode.removeChild(this.form), this.form = null, this.iframe = null),
- f.prototype.doClose.call(this)
- },
- e.prototype.doPoll = function() {
- var a = this,
- b = document.createElement("script");
- this.script && (this.script.parentNode.removeChild(this.script), this.script = null),
- b.async = !0,
- b.src = this.uri(),
- b.onerror = function(b) {
- a.onError("jsonp poll error", b)
- };
- var c = document.getElementsByTagName("script")[0];
- c ? c.parentNode.insertBefore(b, c) : (document.head || document.body).appendChild(b),
- this.script = b;
- var d = "undefined" != typeof navigator && /gecko/i.test(navigator.userAgent);
- d && setTimeout(function() {
- var a = document.createElement("iframe");
- document.body.appendChild(a),
- document.body.removeChild(a)
- },
- 100)
- },
- e.prototype.doWrite = function(a, b) {
- function c() {
- d(),
- b()
- }
- function d() {
- if (e.iframe) try {
- e.form.removeChild(e.iframe)
- } catch(a) {
- e.onError("jsonp polling iframe removal error", a)
- }
- try {
- var b = '<iframe src="javascript:0" name="' + e.iframeId + '">';
- f = document.createElement(b)
- } catch(a) {
- f = document.createElement("iframe"),
- f.name = e.iframeId,
- f.src = "javascript:0"
- }
- f.id = e.iframeId,
- e.form.appendChild(f),
- e.iframe = f
- }
- var e = this;
- if (!this.form) {
- var f, g = document.createElement("form"),
- h = document.createElement("textarea"),
- k = this.iframeId = "eio_iframe_" + this.index;
- g.className = "socketio",
- g.style.position = "absolute",
- g.style.top = "-1000px",
- g.style.left = "-1000px",
- g.target = k,
- g.method = "POST",
- g.setAttribute("accept-charset", "utf-8"),
- h.name = "d",
- g.appendChild(h),
- document.body.appendChild(g),
- this.form = g,
- this.area = h
- }
- this.form.action = this.uri(),
- d(),
- a = a.replace(j, "\\\n"),
- this.area.value = a.replace(i, "\\n");
- try {
- this.form.submit()
- } catch(l) {}
- this.iframe.attachEvent ? this.iframe.onreadystatechange = function() {
- "complete" === e.iframe.readyState && c()
- }: this.iframe.onload = c
- }
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b, c) { (function(b) {
- function d(a) {
- var b = a && a.forceBase64;
- b && (this.supportsBinary = !1),
- this.perMessageDeflate = a.perMessageDeflate,
- this.usingBrowserWebSocket = l && !a.forceNode,
- this.usingBrowserWebSocket || (n = e),
- f.call(this, a)
- }
- var e, f = c(26),
- g = c(27),
- h = c(36),
- i = c(37),
- j = c(38),
- k = c(3)("engine.io-client:websocket"),
- l = b.WebSocket || b.MozWebSocket;
- if ("undefined" == typeof window) try {
- e = c(41)
- } catch(m) {}
- var n = l;
- n || "undefined" != typeof window || (n = e),
- a.exports = d,
- i(d, f),
- d.prototype.name = "websocket",
- d.prototype.supportsBinary = !0,
- d.prototype.doOpen = function() {
- if (this.check()) {
- var a = this.uri(),
- b = void 0,
- c = {
- agent: this.agent,
- perMessageDeflate: this.perMessageDeflate
- };
- c.pfx = this.pfx,
- c.key = this.key,
- c.passphrase = this.passphrase,
- c.cert = this.cert,
- c.ca = this.ca,
- c.ciphers = this.ciphers,
- c.rejectUnauthorized = this.rejectUnauthorized,
- this.extraHeaders && (c.headers = this.extraHeaders),
- this.localAddress && (c.localAddress = this.localAddress);
- try {
- this.ws = this.usingBrowserWebSocket ? new n(a) : new n(a, b, c)
- } catch(d) {
- return this.emit("error", d)
- }
- void 0 === this.ws.binaryType && (this.supportsBinary = !1),
- this.ws.supports && this.ws.supports.binary ? (this.supportsBinary = !0, this.ws.binaryType = "nodebuffer") : this.ws.binaryType = "arraybuffer",
- this.addEventListeners()
- }
- },
- d.prototype.addEventListeners = function() {
- var a = this;
- this.ws.onopen = function() {
- a.onOpen()
- },
- this.ws.onclose = function() {
- a.onClose()
- },
- this.ws.onmessage = function(b) {
- a.onData(b.data)
- },
- this.ws.onerror = function(b) {
- a.onError("websocket error", b)
- }
- },
- d.prototype.write = function(a) {
- function c() {
- d.emit("flush"),
- setTimeout(function() {
- d.writable = !0,
- d.emit("drain")
- },
- 0)
- }
- var d = this;
- this.writable = !1;
- for (var e = a.length,
- f = 0,
- h = e; f < h; f++) !
- function(a) {
- g.encodePacket(a, d.supportsBinary,
- function(f) {
- if (!d.usingBrowserWebSocket) {
- var g = {};
- if (a.options && (g.compress = a.options.compress), d.perMessageDeflate) {
- var h = "string" == typeof f ? b.Buffer.byteLength(f) : f.length;
- h < d.perMessageDeflate.threshold && (g.compress = !1)
- }
- }
- try {
- d.usingBrowserWebSocket ? d.ws.send(f) : d.ws.send(f, g)
- } catch(i) {
- k("websocket closed before onclose event")
- }--e || c()
- })
- } (a[f])
- },
- d.prototype.onClose = function() {
- f.prototype.onClose.call(this)
- },
- d.prototype.doClose = function() {
- "undefined" != typeof this.ws && this.ws.close()
- },
- d.prototype.uri = function() {
- var a = this.query || {},
- b = this.secure ? "wss": "ws",
- c = "";
- this.port && ("wss" === b && 443 !== Number(this.port) || "ws" === b && 80 !== Number(this.port)) && (c = ":" + this.port),
- this.timestampRequests && (a[this.timestampParam] = j()),
- this.supportsBinary || (a.b64 = 1),
- a = h.encode(a),
- a.length && (a = "?" + a);
- var d = this.hostname.indexOf(":") !== -1;
- return b + "://" + (d ? "[" + this.hostname + "]": this.hostname) + c + this.path + a
- },
- d.prototype.check = function() {
- return ! (!n || "__initialize" in n && this.name === d.prototype.name)
- }
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b) {},
- function(a, b) {
- var c = [].indexOf;
- a.exports = function(a, b) {
- if (c) return a.indexOf(b);
- for (var d = 0; d < a.length; ++d) if (a[d] === b) return d;
- return - 1
- }
- },
- function(a, b) { (function(b) {
- var c = /^[\],:{}\s]*$/,
- d = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
- e = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
- f = /(?:^|:|,)(?:\s*\[)+/g,
- g = /^\s+/,
- h = /\s+$/;
- a.exports = function(a) {
- return "string" == typeof a && a ? (a = a.replace(g, "").replace(h, ""), b.JSON && JSON.parse ? JSON.parse(a) : c.test(a.replace(d, "@").replace(e, "]").replace(f, "")) ? new Function("return " + a)() : void 0) : null
- }
- }).call(b,
- function() {
- return this
- } ())
- },
- function(a, b, c) {
- "use strict";
- function d(a, b, c) {
- this.io = a,
- this.nsp = b,
- this.json = this,
- this.ids = 0,
- this.acks = {},
- this.receiveBuffer = [],
- this.sendBuffer = [],
- this.connected = !1,
- this.disconnected = !0,
- c && c.query && (this.query = c.query),
- this.io.autoConnect && this.open()
- }
- var e = c(7),
- f = c(35),
- g = c(45),
- h = c(46),
- i = c(47),
- j = c(3)("socket.io-client:socket"),
- k = c(29);
- a.exports = b = d;
- var l = {
- connect: 1,
- connect_error: 1,
- connect_timeout: 1,
- connecting: 1,
- disconnect: 1,
- error: 1,
- reconnect: 1,
- reconnect_attempt: 1,
- reconnect_failed: 1,
- reconnect_error: 1,
- reconnecting: 1,
- ping: 1,
- pong: 1
- },
- m = f.prototype.emit;
- f(d.prototype),
- d.prototype.subEvents = function() {
- if (!this.subs) {
- var a = this.io;
- this.subs = [h(a, "open", i(this, "onopen")), h(a, "packet", i(this, "onpacket")), h(a, "close", i(this, "onclose"))]
- }
- },
- d.prototype.open = d.prototype.connect = function() {
- return this.connected ? this: (this.subEvents(), this.io.open(), "open" === this.io.readyState && this.onopen(), this.emit("connecting"), this)
- },
- d.prototype.send = function() {
- var a = g(arguments);
- return a.unshift("message"),
- this.emit.apply(this, a),
- this
- },
- d.prototype.emit = function(a) {
- if (l.hasOwnProperty(a)) return m.apply(this, arguments),
- this;
- var b = g(arguments),
- c = e.EVENT;
- k(b) && (c = e.BINARY_EVENT);
- var d = {
- type: c,
- data: b
- };
- return d.options = {},
- d.options.compress = !this.flags || !1 !== this.flags.compress,
- "function" == typeof b[b.length - 1] && (j("emitting packet with ack id %d", this.ids), this.acks[this.ids] = b.pop(), d.id = this.ids++),
- this.connected ? this.packet(d) : this.sendBuffer.push(d),
- delete this.flags,
- this
- },
- d.prototype.packet = function(a) {
- a.nsp = this.nsp,
- this.io.packet(a)
- },
- d.prototype.onopen = function() {
- j("transport is open - connecting"),
- "/" !== this.nsp && (this.query ? this.packet({
- type: e.CONNECT,
- query: this.query
- }) : this.packet({
- type: e.CONNECT
- }))
- },
- d.prototype.onclose = function(a) {
- j("close (%s)", a),
- this.connected = !1,
- this.disconnected = !0,
- delete this.id,
- this.emit("disconnect", a)
- },
- d.prototype.onpacket = function(a) {
- if (a.nsp === this.nsp) switch (a.type) {
- case e.CONNECT:
- this.onconnect();
- break;
- case e.EVENT:
- this.onevent(a);
- break;
- case e.BINARY_EVENT:
- this.onevent(a);
- break;
- case e.ACK:
- this.onack(a);
- break;
- case e.BINARY_ACK:
- this.onack(a);
- break;
- case e.DISCONNECT:
- this.ondisconnect();
- break;
- case e.ERROR:
- this.emit("error", a.data)
- }
- },
- d.prototype.onevent = function(a) {
- var b = a.data || [];
- j("emitting event %j", b),
- null != a.id && (j("attaching ack callback to event"), b.push(this.ack(a.id))),
- this.connected ? m.apply(this, b) : this.receiveBuffer.push(b)
- },
- d.prototype.ack = function(a) {
- var b = this,
- c = !1;
- return function() {
- if (!c) {
- c = !0;
- var d = g(arguments);
- j("sending ack %j", d);
- var f = k(d) ? e.BINARY_ACK: e.ACK;
- b.packet({
- type: f,
- id: a,
- data: d
- })
- }
- }
- },
- d.prototype.onack = function(a) {
- var b = this.acks[a.id];
- "function" == typeof b ? (j("calling ack %s with %j", a.id, a.data), b.apply(this, a.data), delete this.acks[a.id]) : j("bad ack %s", a.id)
- },
- d.prototype.onconnect = function() {
- this.connected = !0,
- this.disconnected = !1,
- this.emit("connect"),
- this.emitBuffered()
- },
- d.prototype.emitBuffered = function() {
- var a;
- for (a = 0; a < this.receiveBuffer.length; a++) m.apply(this, this.receiveBuffer[a]);
- for (this.receiveBuffer = [], a = 0; a < this.sendBuffer.length; a++) this.packet(this.sendBuffer[a]);
- this.sendBuffer = []
- },
- d.prototype.ondisconnect = function() {
- j("server disconnect (%s)", this.nsp),
- this.destroy(),
- this.onclose("io server disconnect")
- },
- d.prototype.destroy = function() {
- if (this.subs) {
- for (var a = 0; a < this.subs.length; a++) this.subs[a].destroy();
- this.subs = null
- }
- this.io.destroy(this)
- },
- d.prototype.close = d.prototype.disconnect = function() {
- return this.connected && (j("performing disconnect (%s)", this.nsp), this.packet({
- type: e.DISCONNECT
- })),
- this.destroy(),
- this.connected && this.onclose("io client disconnect"),
- this
- },
- d.prototype.compress = function(a) {
- return this.flags = this.flags || {},
- this.flags.compress = a,
- this
- }
- },
- function(a, b) {
- function c(a, b) {
- var c = [];
- b = b || 0;
- for (var d = b || 0; d < a.length; d++) c[d - b] = a[d];
- return c
- }
- a.exports = c
- },
- function(a, b) {
- "use strict";
- function c(a, b, c) {
- return a.on(b, c),
- {
- destroy: function() {
- a.removeListener(b, c)
- }
- }
- }
- a.exports = c
- },
- function(a, b) {
- var c = [].slice;
- a.exports = function(a, b) {
- if ("string" == typeof b && (b = a[b]), "function" != typeof b) throw new Error("bind() requires a function");
- var d = c.call(arguments, 2);
- return function() {
- return b.apply(a, d.concat(c.call(arguments)))
- }
- }
- },
- function(a, b) {
- function c(a) {
- a = a || {},
- this.ms = a.min || 100,
- this.max = a.max || 1e4,
- this.factor = a.factor || 2,
- this.jitter = a.jitter > 0 && a.jitter <= 1 ? a.jitter: 0,
- this.attempts = 0
- }
- a.exports = c,
- c.prototype.duration = function() {
- var a = this.ms * Math.pow(this.factor, this.attempts++);
- if (this.jitter) {
- var b = Math.random(),
- c = Math.floor(b * this.jitter * a);
- a = 0 == (1 & Math.floor(10 * b)) ? a - c: a + c
- }
- return 0 | Math.min(a, this.max)
- },
- c.prototype.reset = function() {
- this.attempts = 0
- },
- c.prototype.setMin = function(a) {
- this.ms = a
- },
- c.prototype.setMax = function(a) {
- this.max = a
- },
- c.prototype.setJitter = function(a) {
- this.jitter = a
- }
- }])
- });;
- //////////////////////////////////////////////////////////////////////////////////////
- // //
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� //
- // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈺愨晲鈺愨暆 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺� //
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺� //
- // 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈺氣晲鈺愨晲鈺愨枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅 鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺� //
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺椻枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晽鈺氣枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晳 //
- // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺濃暁鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆 //
- // //
- // 鈺︹晹鈺愨晽鈺� 鈺︹晹鈺愨晽鈺斺晲鈺椻晹鈺愨晽鈺︹晲鈺椻暒鈺斺晲鈺椻晹鈺︹晽 鈺斺晲鈺椻暒 鈺︹晹鈺愨晽鈺斺晽鈺斺晹鈺︹晽 鈺斺晲鈺椻晹鈺︹晽鈺︹晹鈺� //
- // 鈺戔暊鈺愨暎鈺氣晽鈺斺暆鈺犫晲鈺b暁鈺愨晽鈺� 鈺犫暒鈺濃晳鈺犫晲鈺� 鈺� 鈺� 鈺� 鈺戔晳鈺� 鈺戔晳鈺� 鈺� 鈺氣晲鈺� 鈺戔晳鈺犫暕鈺� //
- // 鈺氣暆鈺� 鈺� 鈺氣暆 鈺� 鈺┾暁鈺愨暆鈺氣晲鈺濃暕鈺氣晲鈺┾暕 鈺� 鈺氣晲鈺濃暕鈺愨暆鈺┾暁鈺愨暆鈺濃暁鈺� 鈺� 鈺氣晲鈺濃晲鈺┾暆鈺� 鈺� //
- // 鈹屸攢鈹愨攲鈹€鈹愨敩鈹€鈹� 鈹屸攼鈹屸攲鈹€鈹愨攲鈹攼鈹屸攢鈹� 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹愨攲鈹屸敩鈹� 鈹屸敩鈹愨敩 鈹攲鈹€鈹� 鈹屸攼 鈹攢鈹愨攲鈹€鈹愨敩 鈹攲鈹€鈹愨攲鈹€鈹愨敩鈹€鈹� //
- // 鈹溾敜 鈹� 鈹傗敎鈹敇 鈹傗攤鈹傗攤 鈹� 鈹傗攤鈹溾敜 鈹傗敂鈹€鈹� 鈹溾攢鈹も攤鈹傗攤 鈹傗攤 鈹� 鈹溾攢鈹も敎鈹� 鈹溾敶鈹愨敎鈹敇鈹� 鈹傗攤鈹傗攤鈹斺攢鈹愨敎鈹� 鈹溾敩鈹� //
- // 鈹� 鈹斺攢鈹樷敶鈹斺攢 鈹樷敂鈹樷敂鈹€鈹樷攢鈹粹敇鈹斺攢鈹榦鈹斺敇鈹斺攢鈹� 鈹� 鈹粹敇鈹斺敇鈹€鈹粹敇 鈹� 鈹� 鈹粹敂鈹€鈹� 鈹斺攢鈹樷敶鈹斺攢鈹斺攢鈹樷敂鈹粹敇鈹斺攢鈹樷敂鈹€鈹樷敶鈹斺攢 //
- // //
- //////////////////////////////////////////////////////////////////////////////////////
- /**
- * sails.io.js
- * v1.1.12
- * ------------------------------------------------------------------------
- * JavaScript Client (SDK) for communicating with Sails.
- *
- * Note that this script is completely optional, but it is handy if you're
- * using WebSockets from the browser to talk to your Sails server.
- *
- * For tips and documentation, visit:
- * http://sailsjs.com/documentation/reference/web-sockets/socket-client
- * ------------------------------------------------------------------------
- *
- * This file allows you to send and receive socket.io messages to & from Sails
- * by simulating a REST client interface on top of socket.io. It models its API
- * after the $.ajax pattern from jQuery you might already be familiar with.
- *
- * So if you're switching from using AJAX to sockets, instead of:
- * `$.post( url, [data], [cb] )`
- *
- * You would use:
- * `socket.post( url, [data], [cb] )`
- */
- (function() {
- // 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚枅鈻堚晽 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈻堚枅鈺� 鈻堚枅鈺戔暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆
- // 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺斺枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晽鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔暁鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺� 鈺氣晲鈺愨晲鈺愨枅鈻堚晳
- // 鈺氣枅鈻堚枅鈻堚枅鈻堚晽鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晳
- // 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆 鈺氣晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺愨暆
- //
- /**
- * Constant containing the names of all available options
- * for individual sockets.
- *
- * @type {Array}
- */
- var SOCKET_OPTIONS = ['useCORSRouteToGetCookie', 'url', 'multiplex', 'transports', 'query', 'path', 'headers', 'initialConnectionHeaders', 'reconnection', 'reconnectionAttempts', 'reconnectionDelay', 'reconnectionDelayMax', 'rejectUnauthorized', 'randomizationFactor', 'timeout'];
- /**
- * Constant containing the names of properties on `io.sails` which
- * may be configured using HTML attributes on the script tag which
- * loaded this file.
- *
- * @type {Array}
- *
- * (this is unused if loading from node.js)
- */
- var CONFIGURABLE_VIA_HTML_ATTR = ['autoConnect', 'reconnection', 'environment', 'headers', 'url', 'transports', 'path'];
- /**
- * Constant containing the names of querystring
- * parameters sent when connecting any SailsSocket.
- *
- * @type {Dictionary}
- */
- var CONNECTION_METADATA_PARAMS = {
- version: '__sails_io_sdk_version',
- platform: '__sails_io_sdk_platform',
- language: '__sails_io_sdk_language'
- };
- /**
- * Constant containing metadata about the platform, language, and
- * current version of this SDK.
- *
- * @type {Dictionary}
- */
- var SDK_INFO = {
- version: '1.1.12',
- // <-- pulled automatically from package.json, do not change!
- language: 'javascript',
- platform: (function() {
- if (typeof module === 'object' && typeof module.exports !== 'undefined') {
- return 'node';
- } else {
- return 'browser';
- }
- })()
- };
- // Build `versionString` (a querystring snippet) by
- // combining SDK_INFO and CONNECTION_METADATA_PARAMS.
- SDK_INFO.versionString = CONNECTION_METADATA_PARAMS.version + '=' + SDK_INFO.version + '&' + CONNECTION_METADATA_PARAMS.platform + '=' + SDK_INFO.platform + '&' + CONNECTION_METADATA_PARAMS.language + '=' + SDK_INFO.language;
- // 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚晽 鈻堚枅鈻堚晽鈻堚枅鈺�
- // 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈺戔枅鈻堚晳
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺斺枅鈻堚枅鈻堚晹鈻堚枅鈺戔枅鈻堚晳
- // 鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺戔暁鈻堚枅鈺斺暆鈻堚枅鈺戔枅鈻堚晳
- // 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚枅鈻堚枅鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈺氣晲鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺�
- // 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺�
- //
- // 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺濃暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺戔暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺斺晲鈺愨枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈺氣晲鈺愨晲鈺愨枅鈻堚晳
- // 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳
- // 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆
- //
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽
- // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈺� 鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆鈺氣枅鈻堚晽
- // 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈻堚枅鈺斺枅鈻堚晳 鈻堚枅鈺斺暆 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈺� 鈺氣枅鈻堚晽
- // 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晹鈺濃枅鈻堚晳 鈺氣枅鈻堚晽 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨暆 鈻堚枅鈺� 鈻堚枅鈺斺暆
- // 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈺氣晲鈺� 鈻堚枅鈺� 鈺氣枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺斺暆
- // 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺�
- //
- //
- // If available, grab the DOM element for the script tag which imported this file.
- // (skip this if this SDK is being used outside of the DOM, i.e. in a Node process)
- //
- // This is used below to parse client-side sails.io.js configuration encoded as
- // HTML attributes, as well as grabbing hold of the URL from whence the SDK was fetched.
- var thisScriptTag = (function() {
- if (typeof window !== 'object' || typeof window.document !== 'object' || typeof window.document.getElementsByTagName !== 'function') {
- return null;
- }
- // Return the URL of the last script loaded (i.e. this one)
- // (this must run before nextTick; see http://stackoverflow.com/a/2976714/486547)
- var allScriptsCurrentlyInDOM = window.document.getElementsByTagName('script');
- return allScriptsCurrentlyInDOM[allScriptsCurrentlyInDOM.length - 1];
- })();
- // Variables to contain src URL and other script tag config (for use below).
- var urlThisScriptWasFetchedFrom = '';
- var scriptTagConfig = {};
- if (thisScriptTag) {
- // Save the URL that this script was fetched from.
- urlThisScriptWasFetchedFrom = thisScriptTag.src;
- // Now parse the most common client-side configuration settings
- // from the script tag where they may be encoded as HTML attributes.
- //
- // Any configuration which may be provided as an HTML attribute may
- // also be provided prefixed with `data-`. This is for folks who
- // need to support browsers that have issues with nonstandard
- // HTML attributes (or if the idea of using nonstandard HTML attributes
- // just creeps you out)
- //
- // If a `data-` prefixed attr is provided, it takes precedence.
- // (this is so that if you are already using one of these HTML
- // attrs for some reason, you can keep it as-is and override
- // it using `data-`. If you are using the `data-` prefixed version
- // for some other purpose... well, in that case you'll just have to
- // configure programmatically using `io.sails` instead.)
- CONFIGURABLE_VIA_HTML_ATTR.forEach(function(configKey) {
- scriptTagConfig[configKey] = (function() {
- // Support 'data-' prefixed or normal attributes.
- // (prefixed versions take precedence if provided)
- var htmlAttrVal = thisScriptTag.getAttribute('data-' + configKey);
- if (!htmlAttrVal) {
- htmlAttrVal = thisScriptTag.getAttribute(configKey);
- }
- // The HTML attribute value should always be a string or `null`.
- // We'll try to parse it as JSON and use that, but worst case fall back
- // to the default situation of it being a string.
- if (typeof htmlAttrVal === 'string') {
- try {
- return JSON.parse(htmlAttrVal);
- } catch(e) {
- return htmlAttrVal;
- }
- }
- // If `null` was returned from getAttribute(), it means that the HTML attribute
- // was not specified, so we treat it as undefined (which will cause the property
- // to be removed below)
- else if (htmlAttrVal === null) {
- return undefined;
- }
- // Any other contingency shouldn't be possible:
- // - if no quotes are used in the HTML attribute, it still comes in as a string.
- // - if no RHS is provided for the attribute, it still comes in as "" (empty string)
- // (but we still handle this with an explicit error just in case--for debugging and support purposes)
- else throw new Error('sails.io.js :: Unexpected/invalid script tag configuration for `' + configKey + '`: `' + htmlAttrVal + '` (a `' + typeof htmlAttrVal + '`). Should be a string.');
- })();
- if (scriptTagConfig[configKey] === undefined) {
- delete scriptTagConfig[configKey];
- }
- });
- // Now that they've been parsed, do an extremely lean version of
- // logical type validation/coercion of provided values.
- //////////////////////////////////////////////////////////////////
- // `autoConnect`
- if (typeof scriptTagConfig.autoConnect !== 'undefined') {
- if (scriptTagConfig.autoConnect === '') {
- // Special case for empty string. It means `true` (see above).
- scriptTagConfig.autoConnect = true;
- } else if (typeof scriptTagConfig.autoConnect !== 'boolean') {
- throw new Error('sails.io.js :: Unexpected/invalid configuration for `autoConnect` provided in script tag: `' + scriptTagConfig.autoConnect + '` (a `' + typeof scriptTagConfig.autoConnect + '`). Should be a boolean.');
- }
- }
- // `environment`
- if (typeof scriptTagConfig.environment !== 'undefined') {
- if (typeof scriptTagConfig.environment !== 'string') {
- throw new Error('sails.io.js :: Unexpected/invalid configuration for `environment` provided in script tag: `' + scriptTagConfig.environment + '` (a `' + typeof scriptTagConfig.environment + '`). Should be a string.');
- }
- }
- // `headers`
- if (typeof scriptTagConfig.headers !== 'undefined') {
- if (typeof scriptTagConfig.headers !== 'object' || Array.isArray(scriptTagConfig.headers)) {
- throw new Error('sails.io.js :: Unexpected/invalid configuration for `headers` provided in script tag: `' + scriptTagConfig.headers + '` (a `' + typeof scriptTagConfig.headers + '`). Should be a JSON-compatible dictionary (i.e. `{}`). Don\'t forget those double quotes (""), even on key names! Use single quotes (\'\') to wrap the HTML attribute value; e.g. `headers=\'{"X-Auth": "foo"}\'`');
- }
- }
- // `url`
- if (typeof scriptTagConfig.url !== 'undefined') {
- if (typeof scriptTagConfig.url !== 'string') {
- throw new Error('sails.io.js :: Unexpected/invalid configuration for `url` provided in script tag: `' + scriptTagConfig.url + '` (a `' + typeof scriptTagConfig.url + '`). Should be a string.');
- }
- }
- // OTHER `io.sails` options are NOT CURRENTLY SUPPORTED VIA HTML ATTRIBUTES.
- }
- // Grab a reference to the global socket.io client (if one is available).
- // This is used via closure below to determine which `io` to use when the
- // socket.io client instance (`io`) is augmented to become the Sails client
- // SDK instance (still `io`).
- var _existingGlobalSocketIO = (typeof io !== 'undefined') ? io: undefined;
- //////////////////////////////////////////////////////////////
- /////
- ///// NOW FOR BUNCHES OF:
- ///// - PRIVATE FUNCTION DEFINITIONS
- ///// - CONSTRUCTORS
- ///// - AND METHODS
- /////
- //////////////////////////////////////////////////////////////
- //
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈺愨晲鈺愨暆 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚枅鈻堚晽 鈻堚枅鈺戔暁鈺愨晲鈻堚枅鈺斺晲鈺愨暆
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺斺枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈺�
- // 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈺氣晲鈺愨晲鈺愨暆鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈺濃枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺� 鈻堚枅鈺戔暁鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺�
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆 鈺氣枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳 鈻堚枅鈺�
- // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺愨晲鈺� 鈺氣晲鈺�
- //
- /**
- * SailsIOClient()
- *
- * Augment the provided Socket.io client object (`io`) with methods for
- * talking and listening to one or more Sails backend(s). If no `io` was
- * provided (i.e. in a browser setting), then attempt to use the global.
- *
- * This absorbs implicit `io.sails` configuration, sets a timer for
- * automatically connecting a socket (if `io.sails.autoConnect` is enabled)
- * and returns the augmented `io`.
- *
- * Note:
- * The automatically-connected socket is exposed as `io.socket`. If this
- * socket attempts to bind event listeners or send requests before it is
- * connected, it will be queued up and replayed when the connection is
- * successfully opened.
- *
- * @param {SocketIO} io
- * @returns {SailsIOClient} [also called `io`]
- */
- function SailsIOClient(_providedSocketIO) {
- // First, determine which `io` we're augmenting.
- //
- // Prefer the passed-in `io` instance, but fall back to the
- // global one if we've got it.
- var io;
- if (_providedSocketIO) {
- io = _providedSocketIO;
- } else {
- io = _existingGlobalSocketIO;
- }
- // (note that for readability, we deliberately do not short circuit or use the tertiary operator above)
- // If a socket.io client (`io`) is not available, none of this will work.
- if (!io) {
- // If node:
- if (SDK_INFO.platform === 'node') {
- throw new Error('No socket.io client available. When requiring `sails.io.js` from Node.js, a socket.io client (`io`) must be passed in; e.g.:\n```\nvar io = require(\'sails.io.js\')( require(\'socket.io-client\') )\n```\n(see https://github.com/balderdashy/sails.io.js/tree/master/test for more examples)');
- }
- // Otherwise, this is a web browser:
- else {
- throw new Error('The Sails socket SDK depends on the socket.io client, but the socket.io global (`io`) was not available when `sails.io.js` loaded. Normally, the socket.io client code is bundled with sails.io.js, so something is a little off. Please check to be sure this version of `sails.io.js` has the minified Socket.io client at the top of the file.');
- }
- }
- // If the chosen socket.io client (`io`) has ALREADY BEEN AUGMENTED by this SDK,
- // (i.e. if it already has a `.sails` property) then throw an error.
- if (io.sails) {
- // If node:
- if (SDK_INFO.platform === 'node') {
- throw new Error('The provided socket.io client (`io`) has already been augmented into a Sails socket SDK instance (it has `io.sails`).');
- }
- // Otherwise, this is a web browser:
- else {
- throw new Error('The socket.io client (`io`) has already been augmented into a Sails socket SDK instance. Usually, this means you are bringing `sails.io.js` onto the page more than once.');
- }
- }
- /**
- * A little logger for this library to use internally.
- * Basically just a wrapper around `console.log` with
- * support for feature-detection.
- *
- * @api private
- * @factory
- */
- function LoggerFactory(options) {
- options = options || {
- prefix: true
- };
- // If `console.log` is not accessible, `log` is a noop.
- if (typeof console !== 'object' || typeof console.log !== 'function' || typeof console.log.bind !== 'function') {
- return function noop() {};
- }
- return function log() {
- var args = Array.prototype.slice.call(arguments);
- // All logs are disabled when `io.sails.environment = 'production'`.
- if (io.sails.environment === 'production') return;
- // Add prefix to log messages (unless disabled)
- var PREFIX = '';
- if (options.prefix) {
- args.unshift(PREFIX);
- }
- // Call wrapped logger
- console.log.bind(console).apply(this, args);
- };
- } //</LoggerFactory>
- // Create a private logger instance
- var consolog = LoggerFactory();
- consolog.noPrefix = LoggerFactory({
- prefix: false
- });
- /**
- * What is the `requestQueue`?
- *
- * The request queue is used to simplify app-level connection logic--
- * i.e. so you don't have to wait for the socket to be connected
- * to start trying to synchronize data.
- *
- * @api private
- * @param {SailsSocket} socket
- */
- function runRequestQueue(socket) {
- var queue = socket.requestQueue;
- if (!queue) return;
- for (var i in queue) {
- // Double-check that `queue[i]` will not
- // inadvertently discover extra properties attached to the Object
- // and/or Array prototype by other libraries/frameworks/tools.
- // (e.g. Ember does this. See https://github.com/balderdashy/sails.io.js/pull/5)
- var isSafeToDereference = ({}).hasOwnProperty.call(queue, i);
- if (isSafeToDereference) {
- // Get the arguments that were originally made to the "request" method
- var requestArgs = queue[i];
- // Call the request method again in the context of the socket, with the original args
- socket.request.apply(socket, requestArgs);
- }
- }
- // Now empty the queue to remove it as a source of additional complexity.
- socket.requestQueue = null;
- }
- /**
- * Send a JSONP request.
- *
- * @param {Object} opts [optional]
- * @param {Function} cb
- * @return {XMLHttpRequest}
- */
- function jsonp(opts, cb) {
- opts = opts || {};
- if (typeof window === 'undefined') {
- // FUTURE: refactor node usage to live in here
- return cb();
- }
- var scriptEl = document.createElement('script');
- window._sailsIoJSConnect = function(response) {
- // In rare circumstances our script may have been vaporised.
- // Remove it, but only if it still exists
- // https://github.com/balderdashy/sails.io.js/issues/92
- if (scriptEl && scriptEl.parentNode) {
- scriptEl.parentNode.removeChild(scriptEl);
- }
- cb(response);
- };
- scriptEl.src = opts.url;
- document.getElementsByTagName('head')[0].appendChild(scriptEl);
- }
- // 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺� 鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺�
- // 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚晽 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺�
- // 鈻堚枅 鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晽鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈺濃枅鈻堚晳鈻堚枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺� 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺�
- // 鈺氣枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳 鈺氣枅鈻堚枅鈺斺枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃暁鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺�
- // 鈺氣晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺� 鈺氣晲鈺愨暆鈺氣晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺�
- //
- // 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺�
- // 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚枅鈻堚晽 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨晲鈺� 鈻堚枅鈺斺暆 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺椻暁鈻堚枅鈺�
- // 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚晽 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈺�
- // 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨暆 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨晲鈺� 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晽鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺� 鈻堚枅鈺� 鈻堚枅 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚晽鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈻堚枅鈺� 鈻堚枅鈺�
- // 鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺戔枅鈻堚晳 鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚晳 鈺氣枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈺氣枅鈻堚晽鈺氣枅鈻堚枅鈻堚枅鈺斺暆鈺氣枅鈻堚枅鈺斺枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺�
- // 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨暆 鈺氣晲鈺愨暆鈺氣晲鈺愨暆 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆
- //
- /**
- * The JWR (JSON WebSocket Response) received from a Sails server.
- *
- * @api public
- * @param {Object} responseCtx
- * => :body
- * => :statusCode
- * => :headers
- *
- * @constructor
- */
- function JWR(responseCtx) {
- this.body = responseCtx.body;
- this.headers = responseCtx.headers || {};
- this.statusCode = (typeof responseCtx.statusCode === 'undefined') ? 200 : responseCtx.statusCode;
- // FUTURE: Replace this typeof short-circuit with an assertion (statusCode should always be set)
- if (this.statusCode < 200 || this.statusCode >= 400) {
- // Determine the appropriate error message.
- var msg;
- if (this.statusCode === 0) {
- msg = 'The socket request failed.';
- } else {
- msg = 'Server responded with a ' + this.statusCode + ' status code';
- msg += ':\n```\n' + JSON.stringify(this.body, null, 2) + '\n```';
- // (^^Note that we should always be able to rely on socket.io to give us
- // non-circular data here, so we don't have to worry about wrapping the
- // above in a try...catch)
- }
- // Now build and attach Error instance.
- this.error = new Error(msg);
- }
- }
- JWR.prototype.toString = function() {
- return '[ResponseFromSails]' + ' -- ' + 'Status: ' + this.statusCode + ' -- ' + 'Headers: ' + this.headers + ' -- ' + 'Body: ' + this.body;
- };
- JWR.prototype.toPOJO = function() {
- return {
- body: this.body,
- headers: this.headers,
- statusCode: this.statusCode
- };
- };
- JWR.prototype.pipe = function() {
- // FUTURE: look at substack's stuff
- return new Error('Client-side streaming support not implemented yet.');
- };
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚晽 鈻堚枅鈻堚晽鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚晽 鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽
- // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈺戔枅鈻堚晳鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈺戔枅鈻堚晹鈺濃暁鈻堚枅鈺�
- // 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺斺枅鈻堚枅鈻堚晹鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈻堚枅鈻堚枅鈺斺枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺�
- // 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺戔暁鈻堚枅鈺斺暆鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈺氣枅鈻堚晹鈺濃枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺�
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈺氣晲鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈺氣晲鈺� 鈻堚枅鈺戔暁鈻堚枅鈺椻枅鈻堚晹鈺�
- // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆
- //
- /**
- * @api private
- * @param {SailsSocket} socket [description]
- * @param {Object} requestCtx [description]
- */
- function _emitFrom(socket, requestCtx) {
- if (!socket._raw) {
- throw new Error('Failed to emit from socket- raw SIO socket is missing.');
- }
- // Since callback is embedded in requestCtx,
- // retrieve it and delete the key before continuing.
- var cb = requestCtx.cb;
- delete requestCtx.cb;
- // Name of the appropriate socket.io listener on the server
- // ( === the request method or "verb", e.g. 'get', 'post', 'put', etc. )
- var sailsEndpoint = requestCtx.method;
- socket._raw.emit(sailsEndpoint, requestCtx,
- function serverResponded(responseCtx) {
- // Send back (emulatedHTTPBody, jsonWebSocketResponse)
- if (cb) {
- cb(responseCtx.body, new JWR(responseCtx));
- }
- });
- }
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晳 鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺�
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺�
- // 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺�
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃暁鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晳 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺�
- // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺�
- //
- /**
- * SailsSocket
- *
- * A wrapper for an underlying Socket instance that communicates directly
- * to the Socket.io server running inside of Sails.
- *
- * If no `socket` option is provied, SailsSocket will function as a mock. It will queue socket
- * requests and event handler bindings, replaying them when the raw underlying socket actually
- * connects. This is handy when we don't necessarily have the valid configuration to know
- * WHICH SERVER to talk to yet, etc. It is also used by `io.socket` for your convenience.
- *
- * @constructor
- * @api private
- *
- * ----------------------------------------------------------------------
- * Note: This constructor should not be used directly. To obtain a `SailsSocket`
- * instance of your very own, run:
- * ```
- * var mySocket = io.sails.connect();
- * ```
- * ----------------------------------------------------------------------
- */
- function SailsSocket(opts) {
- var self = this;
- opts = opts || {};
- // Initialize private properties
- self._isConnecting = false;
- self._mightBeAboutToAutoConnect = false;
- // Set up connection options so that they can only be changed when socket is disconnected.
- var _opts = {};
- SOCKET_OPTIONS.forEach(function(option) {
- // Okay to change global headers while socket is connected
- if (option == 'headers') {
- return;
- }
- Object.defineProperty(self, option, {
- get: function() {
- if (option == 'url') {
- return _opts[option] || (self._raw && self._raw.io && self._raw.io.uri);
- }
- return _opts[option];
- },
- set: function(value) {
- // Don't allow value to be changed while socket is connected
- if (self.isConnected() && io.sails.strict !== false && value != _opts[option]) {
- throw new Error('Cannot change value of `' + option + '` while socket is connected.');
- }
- // If socket is attempting to reconnect, stop it.
- if (self._raw && self._raw.io && self._raw.io.reconnecting && !self._raw.io.skipReconnect) {
- self._raw.io.skipReconnect = true;
- consolog('Stopping reconnect; use .reconnect() to connect socket after changing options.');
- }
- _opts[option] = value;
- }
- });
- });
- // Absorb opts into SailsSocket instance
- // See http://sailsjs.com/documentation/reference/web-sockets/socket-client/sails-socket/properties
- // for description of options
- SOCKET_OPTIONS.forEach(function(option) {
- self[option] = opts[option];
- });
- // Set up "eventQueue" to hold event handlers which have not been set on the actual raw socket yet.
- self.eventQueue = {};
- // Listen for special `parseError` event sent from sockets hook on the backend
- // if an error occurs but a valid callback was not received from the client
- // (i.e. so the server had no other way to send back the error information)
- self.on('sails:parseError',
- function(err) {
- consolog('Sails encountered an error parsing a socket message sent from this client, and did not have access to a callback function to respond with.');
- consolog('Error details:', err);
- });
- // FUTURE:
- // Listen for a special private message on any connected that allows the server
- // to set the environment (giving us 100% certainty that we guessed right)
- // However, note that the `console.log`s called before and after connection
- // are still forced to rely on our existing heuristics (to disable, tack #production
- // onto the URL used to fetch this file.)
- } //</SailsSocket>
- /**
- * `SailsSocket.prototype._connect()`
- *
- * Begin connecting this socket to the server.
- *
- * @api private
- */
- SailsSocket.prototype._connect = function() {
- var self = this;
- self._isConnecting = true;
- // Apply `io.sails` config as defaults
- // (now that at least one tick has elapsed)
- // See http://sailsjs.com/documentation/reference/web-sockets/socket-client/sails-socket/properties
- // for description of options and default values
- SOCKET_OPTIONS.forEach(function(option) {
- if ('undefined' == typeof self[option]) {
- self[option] = io.sails[option];
- }
- });
- // Headers that will be sent with the initial request to /socket.io (Node.js only)
- self.extraHeaders = self.initialConnectionHeaders || {};
- // Log a warning if non-Node.js platform attempts to use `initialConnectionHeaders`
- if (self.initialConnectionHeaders && SDK_INFO.platform !== 'node') {
- if (typeof console === 'object' && typeof console.warn === 'function') {
- console.warn('initialConnectionHeaders option available in Node.js only!');
- }
- }
- // Ensure URL has no trailing slash
- self.url = self.url ? self.url.replace(/(\/)$/, '') : undefined;
- // Mix the current SDK version into the query string in
- // the connection request to the server:
- if (typeof self.query === 'string') {
- // (If provided as a string, trim leading question mark,
- // just in case one was provided.)
- self.query = self.query.replace(/^\?/, '');
- self.query += '&' + SDK_INFO.versionString;
- } else if (self.query && typeof self.query === 'object') {
- throw new Error('`query` setting does not currently support configuration as a dictionary (`{}`). Instead, it must be specified as a string like `foo=89&bar=hi`');
- } else if (!self.query) {
- self.query = SDK_INFO.versionString;
- } else {
- throw new Error('Unexpected data type provided for `query` setting: ' + self.query);
- }
- // Determine whether this is a cross-origin socket by examining the
- // hostname and port on the `window.location` object. If it's cross-origin,
- // we'll attempt to get a cookie for the domain so that a Sails session can
- // be established.
- var isXOrigin = (function() {
- // If `window` doesn't exist (i.e. being used from Node.js), then
- // we won't bother attempting to get a cookie. If you're using sockets
- // from Node.js and find you need to share a session between multiple
- // socket connections, you'll need to make an HTTP request to the /__getcookie
- // endpoint of the Sails server (or any endpoint that returns a set-cookie header)
- // and then use the cookie value in the `initialConnectionHeaders` option to
- // io.sails.connect()
- if (typeof window === 'undefined' || typeof window.location === 'undefined') {
- return false;
- }
- // If `self.url` (aka "target") is falsy, then we don't need to worry about it.
- if (typeof self.url !== 'string') {
- return false;
- }
- // Get information about the "target" (`self.url`)
- var targetProtocol = (function() {
- try {
- targetProtocol = self.url.match(/^([a-z]+:\/\/)/i)[1].toLowerCase();
- } catch(e) {}
- targetProtocol = targetProtocol || 'http://';
- return targetProtocol;
- })();
- var isTargetSSL = !!self.url.match('^https');
- var targetPort = (function() {
- try {
- return self.url.match(/^[a-z]+:\/\/[^:]*:([0-9]*)/i)[1];
- } catch(e) {}
- return isTargetSSL ? '443': '80';
- })();
- var targetAfterProtocol = self.url.replace(/^([a-z]+:\/\/)/i, '');
- // If target protocol is different than the actual protocol,
- // then we'll consider this cross-origin.
- if (targetProtocol.replace(/[:\/]/g, '') !== window.location.protocol.replace(/[:\/]/g, '')) {
- return true;
- }
- // If target hostname is different than actual hostname, we'll consider this cross-origin.
- var hasSameHostname = targetAfterProtocol.search(window.location.hostname) === 0;
- if (!hasSameHostname) {
- return true;
- }
- // If no actual port is explicitly set on the `window.location` object,
- // we'll assume either 80 or 443.
- var isLocationSSL = window.location.protocol.match(/https/i);
- var locationPort = (window.location.port + '') || (isLocationSSL ? '443': '80');
- // Finally, if ports don't match, we'll consider this cross-origin.
- if (targetPort !== locationPort) {
- return true;
- }
- // Otherwise, it's the same origin.
- return false;
- })();
- // Prepare to start connecting the socket
- (function selfInvoking(cb) {
- // If this is an attempt at a cross-origin or cross-port
- // socket connection via a browswe, send a JSONP request
- // first to ensure that a valid cookie is available.
- // This can be disabled by setting `io.sails.useCORSRouteToGetCookie`
- // to false.
- //
- // Otherwise, skip the stuff below.
- //
- if (! (self.useCORSRouteToGetCookie && isXOrigin)) {
- return cb();
- }
- // Figure out the x-origin CORS route
- // (Sails provides a default)
- var xOriginCookieURL = self.url;
- if (typeof self.useCORSRouteToGetCookie === 'string') {
- xOriginCookieURL += self.useCORSRouteToGetCookie;
- } else {
- xOriginCookieURL += '/__getcookie';
- }
- // Make the AJAX request (CORS)
- jsonp({
- url: xOriginCookieURL,
- method: 'GET'
- },
- cb);
- })(function goAheadAndActuallyConnect() {
- // Now that we're ready to connect, create a raw underlying Socket
- // using Socket.io and save it as `_raw` (this will start it connecting)
- self._raw = io(self.url, self);
- // If the low-level transport throws an error _while connecting_, then set the _isConnecting flag
- // to false (since we're no longer connecting with any chance of success anyway).
- // Also, in this case (and in dev mode only) log a helpful message.
- self._raw.io.engine.transport.on('error',
- function(err) {
- if (!self._isConnecting) {
- return;
- }
- self._isConnecting = false;
- // Development-only message:
- consolog('=============================================================================');
- consolog('The socket was unable to connect. The server may be offline, or the socket ');
- consolog('may have failed authorization based on its origin or other factors.');
- consolog('You may want to check the values of `sails.config.sockets.beforeConnect` and');
- consolog('`sails.config.sockets.onlyAllowOrigins` in your app.');
- consolog('More info: https://sailsjs.com/config/sockets');
- consolog('');
- consolog('Technical details:');
- consolog(err);
- consolog('=============================================================================');
- });
- // Replay event bindings from the eager socket
- self.replay();
- /**
- * 'connect' event is triggered when the socket establishes a connection
- * successfully.
- */
- self.on('connect',
- function socketConnected() {
- self._isConnecting = false;
- consolog.noPrefix('\n' + '\n' +
- // ' |> ' + '\n' +
- // ' \\___/ '+锔�
- // '\n'+
- ' |> Now connected to Sails.' + '\n' + '\\___/ For help, see: http://bit.ly/1DmTvgK' + '\n' + ' (using sails.io.js ' + io.sails.sdk.platform + ' SDK @v' + io.sails.sdk.version + ')' + '\n' + '\n' + '\n' +
- // '\n'+
- ''
- // ' 鈿擄笌 (development mode)'
- // 'e.g. to send a GET request to Sails via WebSockets, run:'+ '\n' +
- // '`io.socket.get("/foo", function serverRespondedWith (body, jwr) { console.log(body); })`'+ '\n' +
- );
- });
- self.on('disconnect',
- function() {
- self.connectionLostTimestamp = (new Date()).getTime();
- consolog('====================================');
- consolog('Socket was disconnected from Sails.');
- consolog('Usually, this is due to one of the following reasons:' + '\n' + ' -> the server ' + (self.url ? self.url + ' ': '') + 'was taken down' + '\n' + ' -> your browser lost internet connectivity');
- consolog('====================================');
- });
- self.on('reconnecting',
- function(numAttempts) {
- consolog('\n' + ' Socket is trying to reconnect to Sails...\n' + '_-|>_- (attempt #' + numAttempts + ')' + '\n' + '\n');
- });
- self.on('reconnect',
- function(transport, numAttempts) {
- if (!self._isConnecting) {
- self.on('connect', runRequestQueue.bind(self, self));
- }
- var msSinceConnectionLost = ((new Date()).getTime() - self.connectionLostTimestamp);
- var numSecsOffline = (msSinceConnectionLost / 1000);
- consolog('\n' + ' |> Socket reconnected successfully after' + '\n' + '\\___/ being offline for ~' + numSecsOffline + ' seconds.' + '\n' + '\n');
- });
- // 'error' event is triggered if connection can not be established.
- // (usually because of a failed authorization, which is in turn
- // usually due to a missing or invalid cookie)
- self.on('error',
- function failedToConnect(err) {
- self._isConnecting = false;
- ////////////////////////////////////////////////////////////////////////////////////
- // Note:
- // In the future, we could provide a separate event for when a socket cannot connect
- // due to a failed `beforeConnect` (aka "authorization" if you're old school).
- // this could probably be implemented by emitting a special event from the server.
- ////////////////////////////////////////////////////////////////////////////////////
- consolog('Failed to connect socket (possibly due to failed `beforeConnect` on server)', 'Error:', err);
- });
- });
- };
- /**
- * Reconnect the underlying socket.
- *
- * @api public
- */
- SailsSocket.prototype.reconnect = function() {
- if (this._isConnecting) {
- throw new Error('Cannot connect- socket is already connecting');
- }
- if (this.isConnected()) {
- throw new Error('Cannot connect- socket is already connected');
- }
- return this._connect();
- };
- /**
- * Disconnect the underlying socket.
- *
- * @api public
- */
- SailsSocket.prototype.disconnect = function() {
- this._isConnecting = false;
- if (!this.isConnected()) {
- throw new Error('Cannot disconnect- socket is already disconnected');
- }
- return this._raw.disconnect();
- };
- /**
- * isConnected
- *
- * @return {Boolean} whether the socket is connected and able to
- * communicate w/ the server.
- */
- SailsSocket.prototype.isConnected = function() {
- if (!this._raw) {
- return false;
- }
- return !! this._raw.connected;
- };
- /**
- * isConnecting
- *
- * @return {Boolean} whether the socket is in the process of connecting
- * to the server.
- */
- SailsSocket.prototype.isConnecting = function() {
- return this._isConnecting;
- };
- /**
- * isConnecting
- *
- * @return {Boolean} flag that is `true` after a SailsSocket instance is
- * initialized but before one tick of the event loop
- * has passed (so that it hasn't attempted to connect
- * yet, if autoConnect ends up being configured `true`)
- */
- SailsSocket.prototype.mightBeAboutToAutoConnect = function() {
- return this._mightBeAboutToAutoConnect;
- };
- /**
- * [replay description]
- * @return {[type]} [description]
- */
- SailsSocket.prototype.replay = function() {
- var self = this;
- // Pass events and a reference to the request queue
- // off to the self._raw for consumption
- for (var evName in self.eventQueue) {
- for (var i in self.eventQueue[evName]) {
- self._raw.on(evName, self.eventQueue[evName][i]);
- }
- }
- // Bind a one-time function to run the request queue
- // when the self._raw connects.
- if (!self.isConnected()) {
- self._raw.once('connect', runRequestQueue.bind(self, self));
- }
- // Or run it immediately if self._raw is already connected
- else {
- runRequestQueue(self);
- }
- return self;
- };
- /**
- * Chainable method to bind an event to the socket.
- *
- * @param {String} evName [event name]
- * @param {Function} fn [event handler function]
- * @return {SailsSocket}
- */
- SailsSocket.prototype.on = function(evName, fn) {
- // Bind the event to the raw underlying socket if possible.
- if (this._raw) {
- this._raw.on(evName, fn);
- return this;
- }
- // Otherwise queue the event binding.
- if (!this.eventQueue[evName]) {
- this.eventQueue[evName] = [fn];
- } else {
- this.eventQueue[evName].push(fn);
- }
- return this;
- };
- /**
- * Chainable method to unbind an event from the socket.
- *
- * @param {String} evName [event name]
- * @param {Function} fn [event handler function]
- * @return {SailsSocket}
- */
- SailsSocket.prototype.off = function(evName, fn) {
- // Bind the event to the raw underlying socket if possible.
- if (this._raw) {
- this._raw.off(evName, fn);
- return this;
- }
- // Otherwise queue the event binding.
- if (this.eventQueue[evName] && this.eventQueue[evName].indexOf(fn) > -1) {
- this.eventQueue[evName].splice(this.eventQueue[evName].indexOf(fn), 1);
- }
- return this;
- };
- /**
- * Chainable method to unbind all events from the socket.
- *
- * @return {SailsSocket}
- */
- SailsSocket.prototype.removeAllListeners = function() {
- // Bind the event to the raw underlying socket if possible.
- if (this._raw) {
- this._raw.removeAllListeners();
- return this;
- }
- // Otherwise queue the event binding.
- this.eventQueue = {};
- return this;
- };
- /**
- * Simulate a GET request to sails
- * e.g.
- * `socket.get('/user/3', Stats.populate)`
- *
- * @api public
- * @param {String} url :: destination URL
- * @param {Object} data :: parameters to send with the request [optional]
- * @param {Function} cb :: callback function to call when finished [optional]
- */
- SailsSocket.prototype.get = function(url, data, cb) {
- // `data` is optional
- if (typeof data === 'function') {
- cb = data;
- data = {};
- }
- return this.request({
- method: 'get',
- params: data,
- url: url
- },
- cb);
- };
- /**
- * Simulate a POST request to sails
- * e.g.
- * `socket.post('/event', newMeeting, $spinner.hide)`
- *
- * @api public
- * @param {String} url :: destination URL
- * @param {Object} data :: parameters to send with the request [optional]
- * @param {Function} cb :: callback function to call when finished [optional]
- */
- SailsSocket.prototype.post = function(url, data, cb) {
- // `data` is optional
- if (typeof data === 'function') {
- cb = data;
- data = {};
- }
- return this.request({
- method: 'post',
- data: data,
- url: url
- },
- cb);
- };
- /**
- * Simulate a PUT request to sails
- * e.g.
- * `socket.post('/event/3', changedFields, $spinner.hide)`
- *
- * @api public
- * @param {String} url :: destination URL
- * @param {Object} data :: parameters to send with the request [optional]
- * @param {Function} cb :: callback function to call when finished [optional]
- */
- SailsSocket.prototype.put = function(url, data, cb) {
- // `data` is optional
- if (typeof data === 'function') {
- cb = data;
- data = {};
- }
- return this.request({
- method: 'put',
- params: data,
- url: url
- },
- cb);
- };
- /**
- * Simulate a PATCH request to sails
- * e.g.
- * `socket.patch('/event/3', changedFields, $spinner.hide)`
- *
- * @api public
- * @param {String} url :: destination URL
- * @param {Object} data :: parameters to send with the request [optional]
- * @param {Function} cb :: callback function to call when finished [optional]
- */
- SailsSocket.prototype.patch = function(url, data, cb) {
- // `data` is optional
- if (typeof data === 'function') {
- cb = data;
- data = {};
- }
- return this.request({
- method: 'patch',
- params: data,
- url: url
- },
- cb);
- };
- /**
- * Simulate a DELETE request to sails
- * e.g.
- * `socket.delete('/event', $spinner.hide)`
- *
- * @api public
- * @param {String} url :: destination URL
- * @param {Object} data :: parameters to send with the request [optional]
- * @param {Function} cb :: callback function to call when finished [optional]
- */
- SailsSocket.prototype['delete'] = function(url, data, cb) {
- // `data` is optional
- if (typeof data === 'function') {
- cb = data;
- data = {};
- }
- return this.request({
- method: 'delete',
- params: data,
- url: url
- },
- cb);
- };
- /**
- * Simulate an HTTP request to sails
- * e.g.
- * ```
- * socket.request({
- * url:'/user',
- * params: {},
- * method: 'POST',
- * headers: {}
- * }, function (responseBody, JWR) {
- * // ...
- * });
- * ```
- *
- * @api public
- * @option {String} url :: destination URL
- * @option {Object} params :: parameters to send with the request [optional]
- * @option {Object} headers:: headers to send with the request [optional]
- * @option {Function} cb :: callback function to call when finished [optional]
- * @option {String} method :: HTTP request method [optional]
- */
- SailsSocket.prototype.request = function(options, cb) {
- var usage = 'Usage:\n' + 'socket.request( options, [fnToCallWhenComplete] )\n\n' + 'options.url :: e.g. "/foo/bar"' + '\n' + 'options.method :: e.g. "get", "post", "put", or "delete", etc.' + '\n' + 'options.params :: e.g. { emailAddress: "mike@example.com" }' + '\n' + 'options.headers :: e.g. { "x-my-custom-header": "some string" }';
- // Old usage:
- // var usage = 'Usage:\n socket.'+(options.method||'request')+'('+
- // ' destinationURL, [dataToSend], [fnToCallWhenComplete] )';
- // Validate options and callback
- if (typeof cb !== 'undefined' && typeof cb !== 'function') {
- throw new Error('Invalid callback function!\n' + usage);
- }
- if (typeof options !== 'object' || typeof options.url !== 'string') {
- throw new Error('Invalid or missing URL!\n' + usage);
- }
- if (options.method && typeof options.method !== 'string') {
- throw new Error('Invalid `method` provided (should be a string like "post" or "put")\n' + usage);
- }
- if (options.headers && typeof options.headers !== 'object') {
- throw new Error('Invalid `headers` provided (should be a dictionary with string values)\n' + usage);
- }
- if (options.params && typeof options.params !== 'object') {
- throw new Error('Invalid `params` provided (should be a dictionary with JSON-serializable values)\n' + usage);
- }
- if (options.data && typeof options.data !== 'object') {
- throw new Error('Invalid `data` provided (should be a dictionary with JSON-serializable values)\n' + usage);
- }
- // Accept either `params` or `data` for backwards compatibility (but not both!)
- if (options.data && options.params) {
- throw new Error('Cannot specify both `params` and `data`! They are aliases of each other.\n' + usage);
- } else if (options.data) {
- options.params = options.data;
- delete options.data;
- }
- // If this socket is not connected yet, queue up this request
- // instead of sending it.
- // (so it can be replayed when the socket comes online.)
- if (!this.isConnected()) {
- // If no queue array exists for this socket yet, create it.
- this.requestQueue = this.requestQueue || [];
- this.requestQueue.push([options, cb]);
- return;
- }
- // Otherwise, our socket is connected, so continue prepping
- // the request.
- // Default headers to an empty object
- options.headers = options.headers || {};
- // Build a simulated request object
- // (and sanitize/marshal options along the way)
- var requestCtx = {
- method: (options.method || 'get').toLowerCase(),
- headers: options.headers,
- data: options.params || options.data || {},
- // Remove trailing slashes and spaces to make packets smaller.
- url: options.url.replace(/^(.+)\/*\s*$/, '$1'),
- cb: cb
- };
- // Merge global headers in, if there are any.
- if (this.headers && 'object' === typeof this.headers) {
- for (var header in this.headers) {
- if (!options.headers.hasOwnProperty(header)) {
- options.headers[header] = this.headers[header];
- }
- }
- }
- // Send the request.
- _emitFrom(this, requestCtx);
- };
- /**
- * Socket.prototype._request
- *
- * Simulate HTTP over Socket.io.
- *
- * @api private
- * @param {[type]} options [description]
- * @param {Function} cb [description]
- */
- SailsSocket.prototype._request = function(options, cb) {
- throw new Error('`_request()` was a private API deprecated as of v0.11 of the sails.io.js client. Use `.request()` instead.');
- };
- // 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈺愨晲鈺愨暆
- // 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺斺晲鈺愨枅鈻堚晳鈻堚枅鈺戔枅鈻堚晳 鈺氣晲鈺愨晲鈺愨枅鈻堚晳
- // 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺戔枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晳
- // 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆
- //
- // Set an `io.sails` object that may be used for configuration before the
- // first socket connects (i.e. to allow auto-connect behavior to be
- // prevented by setting `io.sails.autoConnect` in an inline script
- // directly after the script tag which loaded this file).
- // 鈹屸攢鈹愨攲鈹€鈹愨攲鈹攼 鈹� 鈹攲鈹€鈹� 鈺斺暒鈺椻晹鈺愨晽鈺斺晲鈺椻晹鈺愨晽鈺� 鈺︹暒 鈺斺暒鈺椻晹鈺愨晽 鈹屸攢鈹愨攲鈹€鈹愨敩鈹€鈹� 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹€鈹愨敩鈹� 鈹屸攢鈹�
- // 鈹斺攢鈹愨敎鈹� 鈹� 鈹� 鈹傗敎鈹€鈹� 鈺戔晳鈺戔暎 鈺犫暎 鈺犫晲鈺b晳 鈺戔晳 鈺� 鈺氣晲鈺� 鈹溾敜 鈹� 鈹傗敎鈹敇 鈹傗攤 鈹� 鈹斺攢鈹愨敎鈹€鈹も攤鈹� 鈹斺攢鈹�
- // 鈹斺攢鈹樷敂鈹€鈹� 鈹� 鈹斺攢鈹樷敶 鈺愨暕鈺濃暁鈺愨暆鈺� 鈺� 鈺┾暁鈺愨暆鈺┾晲鈺濃暕 鈺氣晲鈺� 鈹� 鈹斺攢鈹樷敶鈹斺攢 鈹粹敂鈹€鈹榦鈹斺攢鈹樷敶 鈹粹敶鈹粹攢鈹樷敂鈹€鈹�
- io.sails = {
- // Whether to automatically connect a socket and save it as `io.socket`.
- autoConnect: true,
- // Whether to automatically try to reconnect after connection is lost
- reconnection: false,
- // The route (path) to hit to get a x-origin (CORS) cookie
- // (or true to use the default: '/__getcookie')
- useCORSRouteToGetCookie: true,
- // The environment we're running in.
- // (logs are not displayed when this is set to 'production')
- //
- // Defaults to development unless this script was fetched from a URL
- // that ends in `*.min.js` or '#production' (may also be manually overridden.)
- //
- environment: urlThisScriptWasFetchedFrom.match(/(\#production|\.min\.js)/g) ? 'production': 'development',
- // The version of this sails.io.js client SDK
- sdk: SDK_INFO,
- // Transports to use when communicating with the server, in the order they will be tried
- transports: ['websocket']
- };
- // 鈹屸攢鈹愨攢鈹� 鈹攲鈹攼鈹屸攢鈹愨攲鈹愨攲鈹屸敩鈹� 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹€鈹愨敩鈹� 鈹屸攢鈹� 鈹屸敩鈹愨攲鈹€鈹愨攲鈹€鈹愨攲鈹€鈹愨敩 鈹敩 鈹屸敩鈹愨攲鈹€鈹�
- // 鈹溾敜 鈹屸敶鈹敇 鈹� 鈹溾敜 鈹傗攤鈹� 鈹傗攤 鈹傗攤 鈹� 鈹斺攢鈹愨敎鈹€鈹も攤鈹� 鈹斺攢鈹� 鈹傗攤鈹溾敜 鈹溾敜 鈹溾攢鈹も攤 鈹傗攤 鈹� 鈹斺攢鈹�
- // 鈹斺攢鈹樷敶 鈹斺攢 鈹� 鈹斺攢鈹樷敇鈹斺敇鈹€鈹粹敇 鈹粹敂鈹€鈹榦鈹斺攢鈹樷敶 鈹粹敶鈹粹攢鈹樷敂鈹€鈹� 鈹€鈹粹敇鈹斺攢鈹樷敂 鈹� 鈹粹敂鈹€鈹樷敶鈹€鈹樷敶 鈹斺攢鈹�
- // 鈹� 鈹敩鈹屸敩鈹愨敩 鈹� 鈹屸敩鈹愨敩 鈹攲鈹€鈹� 鈺� 鈺︹晹鈺︹晽鈺斺暒鈺椻暒 鈺斺晲鈺椻晹鈺︹晽鈺斺暒鈺椻暒鈺愨晽鈺︹晹鈺� 鈺� 鈺︹晹鈺︹晽鈺斺晲鈺椻晹鈺愨晽
- // 鈹傗攤鈹傗攤 鈹� 鈹溾攢鈹� 鈹� 鈹溾攢鈹も敎鈹� 鈺犫晲鈺� 鈺� 鈺戔晳鈺戔晳 鈺犫晲鈺� 鈺� 鈺� 鈺犫暒鈺濃晳鈺犫暕鈺椻晳 鈺� 鈺� 鈺戔暎 鈺氣晲鈺�
- // 鈹斺敶鈹樷敶 鈹� 鈹� 鈹� 鈹� 鈹� 鈹粹敂鈹€鈹� 鈺� 鈺� 鈺� 鈺� 鈺┾暕鈺愨暆 鈺� 鈺� 鈺� 鈺� 鈺┾暁鈺愨暕鈺氣晲鈺濃暁鈺愨暆 鈺� 鈺氣晲鈺濃暁鈺愨暆
- // 鈹屸攢鈹愨敩鈹€鈹愨攲鈹€鈹愨攲鈹攼 鈹屸敩鈹愨敩 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹€鈹愨敩鈹€鈹愨敩鈹屸攢鈹愨攲鈹攼 鈹屸敩鈹愨攲鈹€鈹愨攲鈹€鈹�
- // 鈹溾敜 鈹溾敩鈹樷攤 鈹傗攤鈹傗攤 鈹� 鈹溾攢鈹も敎鈹� 鈹斺攢鈹愨攤 鈹溾敩鈹樷攤鈹溾攢鈹� 鈹� 鈹� 鈹溾攢鈹も攤 鈹�
- // 鈹� 鈹粹敂鈹€鈹斺攢鈹樷敶 鈹� 鈹� 鈹� 鈹粹敂鈹€鈹� 鈹斺攢鈹樷敂鈹€鈹樷敶鈹斺攢鈹粹敶 鈹� 鈹� 鈹� 鈹粹敂鈹€鈹�
- //
- // Now fold in config provided as HTML attributes on the script tag:
- // (note that if `io.sails.*` is changed after this script, those changes
- // will still take precedence)
- CONFIGURABLE_VIA_HTML_ATTR.forEach(function(configKey) {
- if (typeof scriptTagConfig[configKey] !== 'undefined') {
- io.sails[configKey] = scriptTagConfig[configKey];
- }
- });
- //////////////////////////////////////////////////////////////////////////////
- // Note that the new HTML attribute configuration style may eventually
- // completely replace the original approach of setting `io.sails` properties,
- // since the new strategy is easier to reason about. Also, it would allow us
- // to remove the timeout below someday.
- //////////////////////////////////////////////////////////////////////////////
- // 鈹攲鈹€鈹� 鈹屸攢鈹愨攲鈹€鈹愨敩鈹� 鈹屸攢鈹� 鈺斺晲鈺椻晹鈺愨晽鈺斺晽鈺斺晹鈺椻晹鈺斺晲鈺椻晹鈺愨晽鈺斺暒鈺� / \
- // 鈹傗攤 鈹� 鈹斺攢鈹愨敎鈹€鈹も攤鈹� 鈹斺攢鈹� 鈺� 鈺� 鈺戔晳鈺戔晳鈺戔晳鈺戔晳鈺� 鈺� 鈺� / /
- // 鈹粹敂鈹€鈹榦鈹斺攢鈹樷敶 鈹粹敶鈹粹攢鈹樷敂鈹€鈹榦鈺氣晲鈺濃暁鈺愨暆鈺濃暁鈺濃暆鈺氣暆鈺氣晲鈺濃暁鈺愨暆 鈺� \ /
- /**
- * Add `io.sails.connect` function as a wrapper for the built-in `io()` aka `io.connect()`
- * method, returning a SailsSocket. This special function respects the configured io.sails
- * connection URL, as well as sending other identifying information (most importantly, the
- * current version of this SDK).
- *
- * @param {String} url [optional]
- * @param {Object} opts [optional]
- * @return {Socket}
- */
- io.sails.connect = function(url, opts) {
- // Make URL optional
- if ('object' === typeof url) {
- opts = url;
- url = null;
- }
- // Default opts to empty object
- opts = opts || {};
- // If explicit connection url is specified, save it to options
- opts.url = url || opts.url || undefined;
- // Instantiate and return a new SailsSocket- and try to connect immediately.
- var socket = new SailsSocket(opts);
- socket._connect();
- return socket;
- };
- // 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚晽 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈻堚晽
- // 鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺愨枅鈻堚晽 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晳 鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈺氣晲鈺愨枅鈻堚晹鈺愨晲鈺�
- // 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈻堚枅鈻堚晹鈺� 鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈺�
- // 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺� 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晳 鈻堚枅鈺斺晲鈻堚枅鈺� 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺�
- // 鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺戔暁鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈺氣枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺�
- // 鈺氣晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺濃暁鈺愨暆 鈺氣晲鈺濃暁鈺愨晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺�
- //
- // io.socket
- //
- // The eager instance of Socket which will automatically try to connect
- // using the host that this js file was served from.
- //
- // This can be disabled or configured by setting properties on `io.sails.*` within the
- // first cycle of the event loop.
- //
- // Build `io.socket` so it exists
- // (note that this DOES NOT start the connection process)
- io.socket = new SailsSocket();
- //
- // This socket is not connected yet, and has not even _started_ connecting.
- //
- // But in the mean time, this eager socket will be queue events bound by the user
- // before the first cycle of the event loop (using `.on()`), which will later
- // be rebound on the raw underlying socket.
- // 鈹屸攢鈹愨攲鈹€鈹愨攲鈹攼 鈹屸攢鈹愨敩 鈹攲鈹攼鈹屸攢鈹� 鈹屸攢鈹愨攲鈹€鈹愨攲鈹愨攲鈹屸攼鈹屸攲鈹€鈹愨攲鈹€鈹愨攲鈹攼 鈹屸敩鈹愨敩鈹屸敩鈹愨攲鈹€鈹愨敩鈹€鈹�
- // 鈹斺攢鈹愨敎鈹� 鈹� 鈹溾攢鈹も攤 鈹� 鈹� 鈹� 鈹傗攢鈹€鈹€鈹� 鈹� 鈹傗攤鈹傗攤鈹傗攤鈹傗敎鈹� 鈹� 鈹� 鈹� 鈹傗攤鈹傗攤鈹溾敜 鈹溾敩鈹�
- // 鈹斺攢鈹樷敂鈹€鈹� 鈹� 鈹� 鈹粹敂鈹€鈹� 鈹� 鈹斺攢鈹� 鈹斺攢鈹樷敂鈹€鈹樷敇鈹斺敇鈹樷敂鈹樷敂鈹€鈹樷敂鈹€鈹� 鈹� 鈹� 鈹粹敶 鈹粹敂鈹€鈹樷敶鈹斺攢
- // If configured to do so, start auto-connecting after the first cycle of the event loop
- // has completed (to allow time for this behavior to be configured/disabled
- // by specifying properties on `io.sails`)
- // Indicate that the autoConnect timer has started.
- io.socket._mightBeAboutToAutoConnect = true;
- setTimeout(function() {
- // Indicate that the autoConect timer fired.
- io.socket._mightBeAboutToAutoConnect = false;
- // If autoConnect is disabled, delete the eager socket (io.socket) and bail out.
- if (io.sails.autoConnect === false || io.sails.autoconnect === false) {
- delete io.socket;
- return;
- }
- // consolog('Eagerly auto-connecting socket to Sails... (requests will be queued in the mean-time)');
- io.socket._connect();
- },
- 0); // </setTimeout>
- // Return the `io` object.
- return io;
- } //</SailsIOClient>
- //
- /////////////////////////////////////////////////////////////////////////////////
- ///// </bunches of private function definitions, constructors, and methods>
- /////////////////////////////////////////////////////////////////////////////////
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈻堚晽 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈺� 鈻堚枅鈺�
- // 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈺氣枅鈻堚晽鈻堚枅鈺斺暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺斺晲鈺愨晲鈻堚枅鈺椻枅鈻堚晹鈺愨晲鈺愨晲鈺濃枅鈻堚晹鈺愨晲鈺愨晲鈺� 鈻堚枅鈺斺晲鈺愨晲鈺愨暆鈻堚枅鈺斺晲鈺愨枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺斺暆
- // 鈻堚枅鈻堚枅鈻堚晽 鈺氣枅鈻堚枅鈺斺暆 鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺椻枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈺斺暆
- // 鈻堚枅鈺斺晲鈺愨暆 鈻堚枅鈺斺枅鈻堚晽 鈻堚枅鈺斺晲鈺愨晲鈺� 鈻堚枅鈺� 鈻堚枅鈺戔暁鈺愨晲鈺愨晲鈻堚枅鈺戔枅鈻堚晹鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨枅鈻堚晳鈻堚枅鈺� 鈻堚枅鈺戔枅鈻堚晹鈺愨枅鈻堚晽
- // 鈻堚枅鈻堚枅鈻堚枅鈻堚晽鈻堚枅鈺斺暆 鈻堚枅鈺椻枅鈻堚晳 鈺氣枅鈻堚枅鈻堚枅鈻堚晹鈺濃枅鈻堚枅鈻堚枅鈻堚枅鈺戔枅鈻堚枅鈻堚枅鈻堚枅鈺� 鈻堚枅鈻堚枅鈻堚枅鈻堚晳鈻堚枅鈻堚枅鈻堚枅鈺斺暆鈻堚枅鈺� 鈻堚枅鈺�
- // 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺� 鈺氣晲鈺濃暁鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺愨暆 鈺氣晲鈺愨晲鈺愨晲鈺愨暆鈺氣晲鈺愨晲鈺愨晲鈺� 鈺氣晲鈺� 鈺氣晲鈺�
- //
- // Add CommonJS support to allow this client SDK to be used from Node.js.
- if (SDK_INFO.platform === 'node') {
- module.exports = SailsIOClient;
- }
- // Add AMD support, registering this client SDK as an anonymous module.
- else if (typeof define === 'function' && define.amd) {
- define([],
- function() {
- return SailsIOClient;
- });
- } else {
- // Otherwise, try to instantiate the client using the global `io`:
- SailsIOClient();
- // Note:
- // If you are modifying this file manually to wrap an existing socket.io client
- // (e.g. to prevent pollution of the global namespace), you can replace the global
- // `io` with your own `io` instance above.
- }
- })();;
- /* eslint-enable */
|