PageRenderTime 36ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/socketTests/bin/main.js

http://github.com/AxGord/Pony
JavaScript | 2649 lines | 2646 code | 1 blank | 2 comment | 620 complexity | a449031d7d88e3397f5fb60f53a8c915 MD5 | raw file
Possible License(s): MIT
  1. // Generated by Haxe
  2. (function (console, $global) { "use strict";
  3. var $estr = function() { return js_Boot.__string_rec(this,''); };
  4. function $extend(from, fields) {
  5. function Inherit() {} Inherit.prototype = from; var proto = new Inherit();
  6. for (var name in fields) proto[name] = fields[name];
  7. if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
  8. return proto;
  9. }
  10. var EReg = function(r,opt) {
  11. opt = opt.split("u").join("");
  12. this.r = new RegExp(r,opt);
  13. };
  14. EReg.__name__ = ["EReg"];
  15. EReg.prototype = {
  16. r: null
  17. ,match: function(s) {
  18. if(this.r.global) this.r.lastIndex = 0;
  19. this.r.m = this.r.exec(s);
  20. this.r.s = s;
  21. return this.r.m != null;
  22. }
  23. ,matched: function(n) {
  24. var tmp;
  25. if(this.r.m != null && n >= 0 && n < this.r.m.length) tmp = this.r.m[n]; else throw new js__$Boot_HaxeError("EReg::matched");
  26. return tmp;
  27. }
  28. ,__class__: EReg
  29. };
  30. var HxOverrides = function() { };
  31. HxOverrides.__name__ = ["HxOverrides"];
  32. HxOverrides.cca = function(s,index) {
  33. var x = s.charCodeAt(index);
  34. if(x != x) return undefined;
  35. return x;
  36. };
  37. HxOverrides.substr = function(s,pos,len) {
  38. if(len == null) len = s.length; else if(len < 0) {
  39. if(pos == 0) len = s.length + len; else return "";
  40. }
  41. if(pos < 0) {
  42. pos = s.length + pos;
  43. if(pos < 0) pos = 0;
  44. }
  45. return s.substr(pos,len);
  46. };
  47. HxOverrides.indexOf = function(a,obj,i) {
  48. var len = a.length;
  49. if(i < 0) {
  50. i += len;
  51. if(i < 0) i = 0;
  52. }
  53. while(i < len) {
  54. if(a[i] === obj) return i;
  55. i++;
  56. }
  57. return -1;
  58. };
  59. HxOverrides.remove = function(a,obj) {
  60. var i = HxOverrides.indexOf(a,obj,0);
  61. if(i == -1) return false;
  62. a.splice(i,1);
  63. return true;
  64. };
  65. HxOverrides.iter = function(a) {
  66. return { cur : 0, arr : a, hasNext : function() {
  67. return this.cur < this.arr.length;
  68. }, next : function() {
  69. return this.arr[this.cur++];
  70. }};
  71. };
  72. var IntIterator = function(min,max) {
  73. this.min = min;
  74. this.max = max;
  75. };
  76. IntIterator.__name__ = ["IntIterator"];
  77. IntIterator.prototype = {
  78. min: null
  79. ,max: null
  80. ,__class__: IntIterator
  81. };
  82. var Lambda = function() { };
  83. Lambda.__name__ = ["Lambda"];
  84. Lambda.exists = function(it,f) {
  85. var $it0 = $iterator(it)();
  86. while( $it0.hasNext() ) {
  87. var x = $it0.next();
  88. if(f(x)) return true;
  89. }
  90. return false;
  91. };
  92. var List = function() {
  93. this.length = 0;
  94. };
  95. List.__name__ = ["List"];
  96. List.prototype = {
  97. h: null
  98. ,q: null
  99. ,length: null
  100. ,add: function(item) {
  101. var x = [item];
  102. if(this.h == null) this.h = x; else this.q[1] = x;
  103. this.q = x;
  104. this.length++;
  105. }
  106. ,push: function(item) {
  107. var x = [item,this.h];
  108. this.h = x;
  109. if(this.q == null) this.q = x;
  110. this.length++;
  111. }
  112. ,pop: function() {
  113. if(this.h == null) return null;
  114. var x = this.h[0];
  115. this.h = this.h[1];
  116. if(this.h == null) this.q = null;
  117. this.length--;
  118. return x;
  119. }
  120. ,remove: function(v) {
  121. var prev = null;
  122. var l = this.h;
  123. while(l != null) {
  124. if(l[0] == v) {
  125. if(prev == null) this.h = l[1]; else prev[1] = l[1];
  126. if(this.q == l) this.q = prev;
  127. this.length--;
  128. return true;
  129. }
  130. prev = l;
  131. l = l[1];
  132. }
  133. return false;
  134. }
  135. ,iterator: function() {
  136. return new _$List_ListIterator(this.h);
  137. }
  138. ,__class__: List
  139. };
  140. var _$List_ListIterator = function(head) {
  141. this.head = head;
  142. this.val = null;
  143. };
  144. _$List_ListIterator.__name__ = ["_List","ListIterator"];
  145. _$List_ListIterator.prototype = {
  146. head: null
  147. ,val: null
  148. ,hasNext: function() {
  149. return this.head != null;
  150. }
  151. ,next: function() {
  152. this.val = this.head[0];
  153. this.head = this.head[1];
  154. return this.val;
  155. }
  156. ,__class__: _$List_ListIterator
  157. };
  158. var Main = function() { };
  159. Main.__name__ = ["Main"];
  160. Main.main = function() {
  161. js_Node.require("source-map-support").install();
  162. haxe_Log.trace("Zero part",{ fileName : "Main.hx", lineNumber : 38, className : "Main", methodName : "main"});
  163. var serv = null;
  164. var cl = new pony_net_SocketClient(null,13579,100);
  165. var tmp;
  166. if(cl.eLog == null) {
  167. var tmp1;
  168. var this2;
  169. this2 = new pony_Priority(null,false,true);
  170. this2.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  171. tmp1 = this2;
  172. tmp = cl.eLog = tmp1;
  173. } else tmp = cl.eLog;
  174. var this1 = tmp;
  175. var listener = { once : false, listener : pony_events_Listener2Type.LFunction2(haxe_Log.trace)};
  176. this1.add(listener);
  177. var tmp2;
  178. if(cl.eError == null) {
  179. var tmp3;
  180. var this4;
  181. this4 = new pony_Priority(null,false,true);
  182. this4.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  183. tmp3 = this4;
  184. tmp2 = cl.eError = tmp3;
  185. } else tmp2 = cl.eError;
  186. var this3 = tmp2;
  187. var listener1 = { once : false, listener : pony_events_Listener2Type.LFunction2(haxe_Log.trace)};
  188. this3.add(listener1);
  189. var tmp4;
  190. if(cl.eConnect == null) {
  191. var tmp5;
  192. var this6;
  193. this6 = new pony_Priority(null,false,true);
  194. this6.compare = pony_events__$Event1_Event1_$Impl_$.compare;
  195. tmp5 = this6;
  196. tmp4 = cl.eConnect = tmp5;
  197. } else tmp4 = cl.eConnect;
  198. var this5 = tmp4;
  199. var listener2 = { once : false, listener : pony_events_Listener1Type.LFunction0(function() {
  200. haxe_Log.trace("Connected",{ fileName : "Main.hx", lineNumber : 45, className : "Main", methodName : "main"});
  201. cl.destroy();
  202. serv.destroy();
  203. if(Main.testCount % 4 != 0) throw new js__$Boot_HaxeError("Wrong test count");
  204. pony_tests_AsyncTests.init(Main.testCount);
  205. Main.firstTest();
  206. })};
  207. this5.add(listener2);
  208. haxe_Timer.delay(function() {
  209. serv = new pony_net_SocketServer(13579);
  210. },100);
  211. };
  212. Main.firstTest = function() {
  213. haxe_Log.trace("First part",{ fileName : "Main.hx", lineNumber : 63, className : "Main", methodName : "firstTest"});
  214. var server = Main.createServer(6001);
  215. var _g1 = 0;
  216. var _g = Main.partCount;
  217. while(_g1 < _g) {
  218. var i = _g1++;
  219. var tmp;
  220. var i1 = [i];
  221. tmp = (function(i1) {
  222. return function() {
  223. return Main.createClient(i1[0]);
  224. };
  225. })(i1);
  226. haxe_Timer.delay(tmp,Main.delay + Main.delay * i);
  227. }
  228. pony_tests_AsyncTests.wait(new IntIterator(0,Main.blockCount),function() {
  229. haxe_Log.trace("Second part",{ fileName : "Main.hx", lineNumber : 68, className : "Main", methodName : "firstTest"});
  230. server.destroy();
  231. var server1 = Main.createServer(6002);
  232. var _g11 = Main.blockCount;
  233. var _g2 = Main.blockCount + Main.partCount;
  234. while(_g11 < _g2) {
  235. var i2 = _g11++;
  236. var tmp1;
  237. var i3 = [i2];
  238. tmp1 = (function(i3) {
  239. return function() {
  240. return Main.createClient(i3[0]);
  241. };
  242. })(i3);
  243. haxe_Timer.delay(tmp1,Main.delay + Main.delay * (i2 - Main.blockCount));
  244. }
  245. pony_tests_AsyncTests.wait(new IntIterator(Main.blockCount,Main.testCount),function() {
  246. server1.destroy();
  247. Main.finish = true;
  248. });
  249. });
  250. };
  251. Main.createServer = function(aPort) {
  252. Main.port = aPort;
  253. var server = new pony_net_SocketServer(aPort);
  254. var listener = { once : false, listener : pony_events_Listener1Type.LFunction1(function(cl) {
  255. var bo = new haxe_io_BytesOutput();
  256. bo.writeString("hi world");
  257. cl.send(bo);
  258. })};
  259. server.eConnect.add(listener);
  260. var listener1 = { once : false, listener : pony_events_Listener2Type.LFunction1(function(bi) {
  261. var i = bi.readInt32();
  262. var b = pony_Tools.readStr(bi);
  263. pony_tests_AsyncTests.assertList.push({ a : "hello user", b : b, pos : { fileName : "Main.hx", lineNumber : 92, className : "Main", methodName : "createServer"}});
  264. pony_tests_AsyncTests.setFlag(Main.partCount + i,{ fileName : "Main.hx", lineNumber : 93, className : "Main", methodName : "createServer"});
  265. })};
  266. server.eData.add(listener1);
  267. return server;
  268. };
  269. Main.createClient = function(i) {
  270. var client = new pony_net_SocketClient(null,Main.port);
  271. var listener = { once : false, listener : pony_events_Listener2Type.LFunction1(function(s) {
  272. pony_tests_AsyncTests.assertList.push({ a : s, b : "hi world", pos : { fileName : "Main.hx", lineNumber : 102, className : "Main", methodName : "createClient"}});
  273. var bo = new haxe_io_BytesOutput();
  274. bo.writeInt32(i);
  275. bo.writeInt32("hello user".length);
  276. bo.writeString("hello user");
  277. client.send(bo);
  278. pony_tests_AsyncTests.setFlag(i,{ fileName : "Main.hx", lineNumber : 107, className : "Main", methodName : "createClient"});
  279. client.destroy();
  280. client = null;
  281. })};
  282. listener.once = true;
  283. client.eString.add(listener,0);
  284. return client;
  285. };
  286. Math.__name__ = ["Math"];
  287. var Reflect = function() { };
  288. Reflect.__name__ = ["Reflect"];
  289. Reflect.field = function(o,field) {
  290. try {
  291. return o[field];
  292. } catch( e ) {
  293. haxe_CallStack.lastException = e;
  294. if (e instanceof js__$Boot_HaxeError) e = e.val;
  295. return null;
  296. }
  297. };
  298. Reflect.isFunction = function(f) {
  299. return typeof(f) == "function" && !(f.__name__ || f.__ename__);
  300. };
  301. Reflect.makeVarArgs = function(f) {
  302. return function() {
  303. var a = Array.prototype.slice.call(arguments);
  304. return f(a);
  305. };
  306. };
  307. var Std = function() { };
  308. Std.__name__ = ["Std"];
  309. Std.string = function(s) {
  310. return js_Boot.__string_rec(s,"");
  311. };
  312. Std.parseInt = function(x) {
  313. var v = parseInt(x,10);
  314. if(v == 0 && (HxOverrides.cca(x,1) == 120 || HxOverrides.cca(x,1) == 88)) v = parseInt(x);
  315. if(isNaN(v)) return null;
  316. return v;
  317. };
  318. var StringBuf = function() {
  319. this.b = "";
  320. };
  321. StringBuf.__name__ = ["StringBuf"];
  322. StringBuf.prototype = {
  323. b: null
  324. ,__class__: StringBuf
  325. };
  326. var StringTools = function() { };
  327. StringTools.__name__ = ["StringTools"];
  328. StringTools.htmlEscape = function(s,quotes) {
  329. s = s.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
  330. return quotes?s.split("\"").join("&quot;").split("'").join("&#039;"):s;
  331. };
  332. StringTools.startsWith = function(s,start) {
  333. return s.length >= start.length && HxOverrides.substr(s,0,start.length) == start;
  334. };
  335. StringTools.isSpace = function(s,pos) {
  336. var c = HxOverrides.cca(s,pos);
  337. return c > 8 && c < 14 || c == 32;
  338. };
  339. StringTools.ltrim = function(s) {
  340. var l = s.length;
  341. var r = 0;
  342. while(r < l && StringTools.isSpace(s,r)) r++;
  343. if(r > 0) return HxOverrides.substr(s,r,l - r); else return s;
  344. };
  345. StringTools.rtrim = function(s) {
  346. var l = s.length;
  347. var r = 0;
  348. while(r < l && StringTools.isSpace(s,l - r - 1)) r++;
  349. if(r > 0) return HxOverrides.substr(s,0,l - r); else return s;
  350. };
  351. StringTools.trim = function(s) {
  352. return StringTools.ltrim(StringTools.rtrim(s));
  353. };
  354. var Type = function() { };
  355. Type.__name__ = ["Type"];
  356. Type.getClassName = function(c) {
  357. var a = c.__name__;
  358. if(a == null) return null;
  359. return a.join(".");
  360. };
  361. Type.createEmptyInstance = function(cl) {
  362. function empty() {}; empty.prototype = cl.prototype;
  363. return new empty();
  364. };
  365. Type.getInstanceFields = function(c) {
  366. var a = [];
  367. for(var i in c.prototype) a.push(i);
  368. HxOverrides.remove(a,"__class__");
  369. HxOverrides.remove(a,"__properties__");
  370. return a;
  371. };
  372. var _$UInt_UInt_$Impl_$ = {};
  373. _$UInt_UInt_$Impl_$.__name__ = ["_UInt","UInt_Impl_"];
  374. _$UInt_UInt_$Impl_$.gt = function(a,b) {
  375. var aNeg = a < 0;
  376. var bNeg = b < 0;
  377. return aNeg != bNeg?aNeg:a > b;
  378. };
  379. _$UInt_UInt_$Impl_$.gte = function(a,b) {
  380. var aNeg = a < 0;
  381. var bNeg = b < 0;
  382. return aNeg != bNeg?aNeg:a >= b;
  383. };
  384. var haxe_StackItem = { __ename__ : true, __constructs__ : ["CFunction","Module","FilePos","Method","LocalFunction"] };
  385. haxe_StackItem.CFunction = ["CFunction",0];
  386. haxe_StackItem.CFunction.toString = $estr;
  387. haxe_StackItem.CFunction.__enum__ = haxe_StackItem;
  388. haxe_StackItem.Module = function(m) { var $x = ["Module",1,m]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; };
  389. haxe_StackItem.FilePos = function(s,file,line) { var $x = ["FilePos",2,s,file,line]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; };
  390. haxe_StackItem.Method = function(classname,method) { var $x = ["Method",3,classname,method]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; };
  391. haxe_StackItem.LocalFunction = function(v) { var $x = ["LocalFunction",4,v]; $x.__enum__ = haxe_StackItem; $x.toString = $estr; return $x; };
  392. var haxe_CallStack = function() { };
  393. haxe_CallStack.__name__ = ["haxe","CallStack"];
  394. haxe_CallStack.getStack = function(e) {
  395. if(e == null) return [];
  396. var oldValue = Error.prepareStackTrace;
  397. Error.prepareStackTrace = function(error,callsites) {
  398. var stack = [];
  399. var _g = 0;
  400. while(_g < callsites.length) {
  401. var site = callsites[_g];
  402. ++_g;
  403. if(haxe_CallStack.wrapCallSite != null) site = haxe_CallStack.wrapCallSite(site);
  404. var method = null;
  405. var fullName = site.getFunctionName();
  406. if(fullName != null) {
  407. var idx = fullName.lastIndexOf(".");
  408. if(idx >= 0) {
  409. var className = HxOverrides.substr(fullName,0,idx);
  410. var methodName = HxOverrides.substr(fullName,idx + 1,null);
  411. method = haxe_StackItem.Method(className,methodName);
  412. }
  413. }
  414. stack.push(haxe_StackItem.FilePos(method,site.getFileName(),site.getLineNumber()));
  415. }
  416. return stack;
  417. };
  418. var a = haxe_CallStack.makeStack(e.stack);
  419. Error.prepareStackTrace = oldValue;
  420. return a;
  421. };
  422. haxe_CallStack.exceptionStack = function() {
  423. return haxe_CallStack.getStack(haxe_CallStack.lastException);
  424. };
  425. haxe_CallStack.toString = function(stack) {
  426. var b = new StringBuf();
  427. var _g = 0;
  428. while(_g < stack.length) {
  429. var s = stack[_g];
  430. ++_g;
  431. b.b += "\nCalled from ";
  432. haxe_CallStack.itemToString(b,s);
  433. }
  434. return b.b;
  435. };
  436. haxe_CallStack.itemToString = function(b,s) {
  437. switch(s[1]) {
  438. case 0:
  439. b.b += "a C function";
  440. break;
  441. case 1:
  442. var m = s[2];
  443. b.b += "module ";
  444. b.b += m == null?"null":"" + m;
  445. break;
  446. case 2:
  447. var line = s[4];
  448. var file = s[3];
  449. var s1 = s[2];
  450. if(s1 != null) {
  451. haxe_CallStack.itemToString(b,s1);
  452. b.b += " (";
  453. }
  454. b.b += file == null?"null":"" + file;
  455. b.b += " line ";
  456. b.b += line == null?"null":"" + line;
  457. if(s1 != null) b.b += ")";
  458. break;
  459. case 3:
  460. var meth = s[3];
  461. var cname = s[2];
  462. b.b += cname == null?"null":"" + cname;
  463. b.b += ".";
  464. b.b += meth == null?"null":"" + meth;
  465. break;
  466. case 4:
  467. var n = s[2];
  468. b.b += "local function #";
  469. b.b += n == null?"null":"" + n;
  470. break;
  471. }
  472. };
  473. haxe_CallStack.makeStack = function(s) {
  474. if(s == null) return []; else if(typeof(s) == "string") {
  475. var stack = s.split("\n");
  476. if(stack[0] == "Error") stack.shift();
  477. var m = [];
  478. var rie10 = new EReg("^ at ([A-Za-z0-9_. ]+) \\(([^)]+):([0-9]+):([0-9]+)\\)$","");
  479. var _g = 0;
  480. while(_g < stack.length) {
  481. var line = stack[_g];
  482. ++_g;
  483. if(rie10.match(line)) {
  484. var path = rie10.matched(1).split(".");
  485. var meth = path.pop();
  486. var file = rie10.matched(2);
  487. var line1 = Std.parseInt(rie10.matched(3));
  488. m.push(haxe_StackItem.FilePos(meth == "Anonymous function"?haxe_StackItem.LocalFunction():meth == "Global code"?null:haxe_StackItem.Method(path.join("."),meth),file,line1));
  489. } else m.push(haxe_StackItem.Module(StringTools.trim(line)));
  490. }
  491. return m;
  492. } else return s;
  493. };
  494. var haxe_IMap = function() { };
  495. haxe_IMap.__name__ = ["haxe","IMap"];
  496. var haxe_Log = function() { };
  497. haxe_Log.__name__ = ["haxe","Log"];
  498. haxe_Log.trace = function(v,infos) {
  499. js_Boot.__trace(v,infos);
  500. };
  501. var haxe_Timer = function(time_ms) {
  502. var me = this;
  503. this.id = setInterval(function() {
  504. me.run();
  505. },time_ms);
  506. };
  507. haxe_Timer.__name__ = ["haxe","Timer"];
  508. haxe_Timer.delay = function(f,time_ms) {
  509. var t = new haxe_Timer(time_ms);
  510. t.run = function() {
  511. t.stop();
  512. f();
  513. };
  514. return t;
  515. };
  516. haxe_Timer.prototype = {
  517. id: null
  518. ,stop: function() {
  519. if(this.id == null) return;
  520. clearInterval(this.id);
  521. this.id = null;
  522. }
  523. ,run: function() {
  524. }
  525. ,__class__: haxe_Timer
  526. };
  527. var haxe_ds_IntMap = function() {
  528. this.h = { };
  529. };
  530. haxe_ds_IntMap.__name__ = ["haxe","ds","IntMap"];
  531. haxe_ds_IntMap.__interfaces__ = [haxe_IMap];
  532. haxe_ds_IntMap.prototype = {
  533. h: null
  534. ,remove: function(key) {
  535. if(!this.h.hasOwnProperty(key)) return false;
  536. delete(this.h[key]);
  537. return true;
  538. }
  539. ,keys: function() {
  540. var a = [];
  541. for( var key in this.h ) {
  542. if(this.h.hasOwnProperty(key)) a.push(key | 0);
  543. }
  544. return HxOverrides.iter(a);
  545. }
  546. ,iterator: function() {
  547. return { ref : this.h, it : this.keys(), hasNext : function() {
  548. return this.it.hasNext();
  549. }, next : function() {
  550. var i = this.it.next();
  551. return this.ref[i];
  552. }};
  553. }
  554. ,__class__: haxe_ds_IntMap
  555. };
  556. var haxe_io_Bytes = function(length,b) {
  557. this.length = length;
  558. this.b = b;
  559. };
  560. haxe_io_Bytes.__name__ = ["haxe","io","Bytes"];
  561. haxe_io_Bytes.alloc = function(length) {
  562. return new haxe_io_Bytes(length,new Buffer(length));
  563. };
  564. haxe_io_Bytes.ofString = function(s) {
  565. var nb = new Buffer(s,"utf8");
  566. return new haxe_io_Bytes(nb.length,nb);
  567. };
  568. haxe_io_Bytes.ofData = function(b) {
  569. return new haxe_io_Bytes(b.length,b);
  570. };
  571. haxe_io_Bytes.prototype = {
  572. length: null
  573. ,b: null
  574. ,getString: function(pos,len) {
  575. if(pos < 0 || len < 0 || pos + len > this.length) throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds);
  576. var s = "";
  577. var b = this.b;
  578. var fcc = String.fromCharCode;
  579. var i = pos;
  580. var max = pos + len;
  581. while(i < max) {
  582. var c = b[i++];
  583. if(c < 128) {
  584. if(c == 0) break;
  585. s += fcc(c);
  586. } else if(c < 224) s += fcc((c & 63) << 6 | b[i++] & 127); else if(c < 240) {
  587. var c2 = b[i++];
  588. s += fcc((c & 31) << 12 | (c2 & 127) << 6 | b[i++] & 127);
  589. } else {
  590. var c21 = b[i++];
  591. var c3 = b[i++];
  592. s += fcc((c & 15) << 18 | (c21 & 127) << 12 | c3 << 6 & 127 | b[i++] & 127);
  593. }
  594. }
  595. return s;
  596. }
  597. ,toString: function() {
  598. return this.getString(0,this.length);
  599. }
  600. ,__class__: haxe_io_Bytes
  601. };
  602. var haxe_io_BytesBuffer = function() {
  603. this.b = [];
  604. };
  605. haxe_io_BytesBuffer.__name__ = ["haxe","io","BytesBuffer"];
  606. haxe_io_BytesBuffer.prototype = {
  607. b: null
  608. ,getBytes: function() {
  609. var nb = new Buffer(this.b);
  610. var bytes = new haxe_io_Bytes(nb.length,nb);
  611. this.b = null;
  612. return bytes;
  613. }
  614. ,__class__: haxe_io_BytesBuffer
  615. };
  616. var haxe_io_Input = function() { };
  617. haxe_io_Input.__name__ = ["haxe","io","Input"];
  618. haxe_io_Input.prototype = {
  619. bigEndian: null
  620. ,readByte: function() {
  621. throw new js__$Boot_HaxeError("Not implemented");
  622. }
  623. ,readBytes: function(s,pos,len) {
  624. var k = len;
  625. var b = s.b;
  626. if(pos < 0 || len < 0 || pos + len > s.length) throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds);
  627. while(k > 0) {
  628. b[pos] = this.readByte();
  629. pos++;
  630. k--;
  631. }
  632. return len;
  633. }
  634. ,readFullBytes: function(s,pos,len) {
  635. while(len > 0) {
  636. var k = this.readBytes(s,pos,len);
  637. pos += k;
  638. len -= k;
  639. }
  640. }
  641. ,read: function(nbytes) {
  642. var s = haxe_io_Bytes.alloc(nbytes);
  643. var p = 0;
  644. while(nbytes > 0) {
  645. var k = this.readBytes(s,p,nbytes);
  646. if(k == 0) throw new js__$Boot_HaxeError(haxe_io_Error.Blocked);
  647. p += k;
  648. nbytes -= k;
  649. }
  650. return s;
  651. }
  652. ,readInt32: function() {
  653. var ch1 = this.readByte();
  654. var ch2 = this.readByte();
  655. var ch3 = this.readByte();
  656. var ch4 = this.readByte();
  657. return this.bigEndian?ch4 | ch3 << 8 | ch2 << 16 | ch1 << 24:ch1 | ch2 << 8 | ch3 << 16 | ch4 << 24;
  658. }
  659. ,readString: function(len) {
  660. var b = haxe_io_Bytes.alloc(len);
  661. this.readFullBytes(b,0,len);
  662. return b.toString();
  663. }
  664. ,__class__: haxe_io_Input
  665. };
  666. var haxe_io_BytesInput = function(b,pos,len) {
  667. if(pos == null) pos = 0;
  668. if(len == null) len = b.length - pos;
  669. if(pos < 0 || len < 0 || pos + len > b.length) throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds);
  670. this.b = b.b;
  671. this.pos = pos;
  672. this.len = len;
  673. this.totlen = len;
  674. };
  675. haxe_io_BytesInput.__name__ = ["haxe","io","BytesInput"];
  676. haxe_io_BytesInput.__super__ = haxe_io_Input;
  677. haxe_io_BytesInput.prototype = $extend(haxe_io_Input.prototype,{
  678. b: null
  679. ,pos: null
  680. ,len: null
  681. ,totlen: null
  682. ,readByte: function() {
  683. if(this.len == 0) throw new js__$Boot_HaxeError(new haxe_io_Eof());
  684. this.len--;
  685. return this.b[this.pos++];
  686. }
  687. ,readBytes: function(buf,pos,len) {
  688. if(pos < 0 || len < 0 || pos + len > buf.length) throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds);
  689. if(this.len == 0 && len > 0) throw new js__$Boot_HaxeError(new haxe_io_Eof());
  690. if(this.len < len) len = this.len;
  691. var b1 = this.b;
  692. var b2 = buf.b;
  693. var _g = 0;
  694. while(_g < len) {
  695. var i = _g++;
  696. b2[pos + i] = b1[this.pos + i];
  697. }
  698. this.pos += len;
  699. this.len -= len;
  700. return len;
  701. }
  702. ,__class__: haxe_io_BytesInput
  703. });
  704. var haxe_io_Output = function() { };
  705. haxe_io_Output.__name__ = ["haxe","io","Output"];
  706. haxe_io_Output.prototype = {
  707. bigEndian: null
  708. ,writeByte: function(c) {
  709. throw new js__$Boot_HaxeError("Not implemented");
  710. }
  711. ,writeBytes: function(s,pos,len) {
  712. var k = len;
  713. var b = s.b;
  714. if(pos < 0 || len < 0 || pos + len > s.length) throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds);
  715. while(k > 0) {
  716. this.writeByte(b[pos]);
  717. pos++;
  718. k--;
  719. }
  720. return len;
  721. }
  722. ,write: function(s) {
  723. var l = s.length;
  724. var p = 0;
  725. while(l > 0) {
  726. var k = this.writeBytes(s,p,l);
  727. if(k == 0) throw new js__$Boot_HaxeError(haxe_io_Error.Blocked);
  728. p += k;
  729. l -= k;
  730. }
  731. }
  732. ,writeFullBytes: function(s,pos,len) {
  733. while(len > 0) {
  734. var k = this.writeBytes(s,pos,len);
  735. pos += k;
  736. len -= k;
  737. }
  738. }
  739. ,writeInt32: function(x) {
  740. if(this.bigEndian) {
  741. this.writeByte(x >>> 24);
  742. this.writeByte(x >> 16 & 255);
  743. this.writeByte(x >> 8 & 255);
  744. this.writeByte(x & 255);
  745. } else {
  746. this.writeByte(x & 255);
  747. this.writeByte(x >> 8 & 255);
  748. this.writeByte(x >> 16 & 255);
  749. this.writeByte(x >>> 24);
  750. }
  751. }
  752. ,writeString: function(s) {
  753. var b = haxe_io_Bytes.ofString(s);
  754. this.writeFullBytes(b,0,b.length);
  755. }
  756. ,__class__: haxe_io_Output
  757. };
  758. var haxe_io_BytesOutput = function() {
  759. this.b = new haxe_io_BytesBuffer();
  760. };
  761. haxe_io_BytesOutput.__name__ = ["haxe","io","BytesOutput"];
  762. haxe_io_BytesOutput.__super__ = haxe_io_Output;
  763. haxe_io_BytesOutput.prototype = $extend(haxe_io_Output.prototype,{
  764. b: null
  765. ,writeByte: function(c) {
  766. this.b.b.push(c);
  767. }
  768. ,writeBytes: function(buf,pos,len) {
  769. var _this = this.b;
  770. if(pos < 0 || len < 0 || pos + len > buf.length) throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds);
  771. var b2 = buf.b;
  772. var _g1 = pos;
  773. var _g = pos + len;
  774. while(_g1 < _g) {
  775. var i = _g1++;
  776. _this.b.push(b2[i]);
  777. }
  778. return len;
  779. }
  780. ,getBytes: function() {
  781. return this.b.getBytes();
  782. }
  783. ,__class__: haxe_io_BytesOutput
  784. });
  785. var haxe_io_Eof = function() {
  786. };
  787. haxe_io_Eof.__name__ = ["haxe","io","Eof"];
  788. haxe_io_Eof.prototype = {
  789. toString: function() {
  790. return "Eof";
  791. }
  792. ,__class__: haxe_io_Eof
  793. };
  794. var haxe_io_Error = { __ename__ : true, __constructs__ : ["Blocked","Overflow","OutsideBounds","Custom"] };
  795. haxe_io_Error.Blocked = ["Blocked",0];
  796. haxe_io_Error.Blocked.toString = $estr;
  797. haxe_io_Error.Blocked.__enum__ = haxe_io_Error;
  798. haxe_io_Error.Overflow = ["Overflow",1];
  799. haxe_io_Error.Overflow.toString = $estr;
  800. haxe_io_Error.Overflow.__enum__ = haxe_io_Error;
  801. haxe_io_Error.OutsideBounds = ["OutsideBounds",2];
  802. haxe_io_Error.OutsideBounds.toString = $estr;
  803. haxe_io_Error.OutsideBounds.__enum__ = haxe_io_Error;
  804. haxe_io_Error.Custom = function(e) { var $x = ["Custom",3,e]; $x.__enum__ = haxe_io_Error; $x.toString = $estr; return $x; };
  805. var haxe_unit_TestCase = function() {
  806. };
  807. haxe_unit_TestCase.__name__ = ["haxe","unit","TestCase"];
  808. haxe_unit_TestCase.prototype = {
  809. currentTest: null
  810. ,setup: function() {
  811. }
  812. ,tearDown: function() {
  813. }
  814. ,print: function(v) {
  815. haxe_unit_TestRunner.print(v);
  816. }
  817. ,assertTrue: function(b,c) {
  818. this.currentTest.done = true;
  819. if(b != true) {
  820. this.currentTest.success = false;
  821. this.currentTest.error = "expected true but was false";
  822. this.currentTest.posInfos = c;
  823. throw new js__$Boot_HaxeError(this.currentTest);
  824. }
  825. }
  826. ,assertFalse: function(b,c) {
  827. this.currentTest.done = true;
  828. if(b == true) {
  829. this.currentTest.success = false;
  830. this.currentTest.error = "expected false but was true";
  831. this.currentTest.posInfos = c;
  832. throw new js__$Boot_HaxeError(this.currentTest);
  833. }
  834. }
  835. ,assertEquals: function(expected,actual,c) {
  836. this.currentTest.done = true;
  837. if(actual != expected) {
  838. this.currentTest.success = false;
  839. this.currentTest.error = "expected '" + Std.string(expected) + "' but was '" + Std.string(actual) + "'";
  840. this.currentTest.posInfos = c;
  841. throw new js__$Boot_HaxeError(this.currentTest);
  842. }
  843. }
  844. ,__class__: haxe_unit_TestCase
  845. };
  846. var haxe_unit_TestResult = function() {
  847. this.m_tests = new List();
  848. this.success = true;
  849. };
  850. haxe_unit_TestResult.__name__ = ["haxe","unit","TestResult"];
  851. haxe_unit_TestResult.prototype = {
  852. m_tests: null
  853. ,success: null
  854. ,add: function(t) {
  855. this.m_tests.add(t);
  856. if(!t.success) this.success = false;
  857. }
  858. ,toString: function() {
  859. var buf_b = "";
  860. var failures = 0;
  861. var _g_head = this.m_tests.h;
  862. var _g_val = null;
  863. while(_g_head != null) {
  864. var tmp;
  865. _g_val = _g_head[0];
  866. _g_head = _g_head[1];
  867. tmp = _g_val;
  868. var test = tmp;
  869. if(test.success == false) {
  870. buf_b += "* ";
  871. buf_b += test.classname == null?"null":"" + test.classname;
  872. buf_b += "::";
  873. buf_b += test.method == null?"null":"" + test.method;
  874. buf_b += "()";
  875. buf_b += "\n";
  876. buf_b += "ERR: ";
  877. if(test.posInfos != null) {
  878. buf_b += Std.string(test.posInfos.fileName);
  879. buf_b += ":";
  880. buf_b += Std.string(test.posInfos.lineNumber);
  881. buf_b += "(";
  882. buf_b += Std.string(test.posInfos.className);
  883. buf_b += ".";
  884. buf_b += Std.string(test.posInfos.methodName);
  885. buf_b += ") - ";
  886. }
  887. buf_b += test.error == null?"null":"" + test.error;
  888. buf_b += "\n";
  889. if(test.backtrace != null) {
  890. buf_b += test.backtrace == null?"null":"" + test.backtrace;
  891. buf_b += "\n";
  892. }
  893. buf_b += "\n";
  894. failures++;
  895. }
  896. }
  897. buf_b += "\n";
  898. if(failures == 0) buf_b += "OK "; else buf_b += "FAILED ";
  899. buf_b += Std.string(this.m_tests.length);
  900. buf_b += " tests, ";
  901. buf_b += failures == null?"null":"" + failures;
  902. buf_b += " failed, ";
  903. buf_b += Std.string(this.m_tests.length - failures);
  904. buf_b += " success";
  905. buf_b += "\n";
  906. return buf_b;
  907. }
  908. ,__class__: haxe_unit_TestResult
  909. };
  910. var haxe_unit_TestRunner = function() {
  911. this.result = new haxe_unit_TestResult();
  912. this.cases = new List();
  913. };
  914. haxe_unit_TestRunner.__name__ = ["haxe","unit","TestRunner"];
  915. haxe_unit_TestRunner.print = function(v) {
  916. var msg = js_Boot.__string_rec(v,"");
  917. var d;
  918. if(typeof(document) != "undefined" && (d = document.getElementById("haxe:trace")) != null) {
  919. msg = StringTools.htmlEscape(msg).split("\n").join("<br/>");
  920. d.innerHTML += msg + "<br/>";
  921. } else if(typeof process != "undefined" && process.stdout != null && process.stdout.write != null) process.stdout.write(msg); else if(typeof console != "undefined" && console.log != null) console.log(msg);
  922. };
  923. haxe_unit_TestRunner.customTrace = function(v,p) {
  924. haxe_unit_TestRunner.print(p.fileName + ":" + p.lineNumber + ": " + Std.string(v) + "\n");
  925. };
  926. haxe_unit_TestRunner.prototype = {
  927. result: null
  928. ,cases: null
  929. ,add: function(c) {
  930. this.cases.add(c);
  931. }
  932. ,run: function() {
  933. this.result = new haxe_unit_TestResult();
  934. var _g_head = this.cases.h;
  935. var _g_val = null;
  936. while(_g_head != null) {
  937. var tmp;
  938. _g_val = _g_head[0];
  939. _g_head = _g_head[1];
  940. tmp = _g_val;
  941. var c = tmp;
  942. this.runCase(c);
  943. }
  944. haxe_unit_TestRunner.print(this.result.toString());
  945. return this.result.success;
  946. }
  947. ,runCase: function(t) {
  948. var old = haxe_Log.trace;
  949. haxe_Log.trace = haxe_unit_TestRunner.customTrace;
  950. var cl = t == null?null:js_Boot.getClass(t);
  951. var fields = Type.getInstanceFields(cl);
  952. haxe_unit_TestRunner.print("Class: " + Type.getClassName(cl) + " ");
  953. var _g = 0;
  954. while(_g < fields.length) {
  955. var f = fields[_g];
  956. ++_g;
  957. var field = Reflect.field(t,f);
  958. if(StringTools.startsWith(f,"test") && Reflect.isFunction(field)) {
  959. t.currentTest = new haxe_unit_TestStatus();
  960. t.currentTest.classname = Type.getClassName(cl);
  961. t.currentTest.method = f;
  962. t.setup();
  963. try {
  964. var args = [];
  965. field.apply(t,args);
  966. if(t.currentTest.done) {
  967. t.currentTest.success = true;
  968. haxe_unit_TestRunner.print(".");
  969. } else {
  970. t.currentTest.success = false;
  971. t.currentTest.error = "(warning) no assert";
  972. haxe_unit_TestRunner.print("W");
  973. }
  974. } catch( $e0 ) {
  975. haxe_CallStack.lastException = $e0;
  976. if ($e0 instanceof js__$Boot_HaxeError) $e0 = $e0.val;
  977. if( js_Boot.__instanceof($e0,haxe_unit_TestStatus) ) {
  978. var e = $e0;
  979. haxe_unit_TestRunner.print("F");
  980. t.currentTest.backtrace = haxe_CallStack.toString(haxe_CallStack.exceptionStack());
  981. } else {
  982. var e1 = $e0;
  983. haxe_unit_TestRunner.print("E");
  984. if(e1.message != null) t.currentTest.error = "exception thrown : " + Std.string(e1) + " [" + Std.string(e1.message) + "]"; else t.currentTest.error = "exception thrown : " + Std.string(e1);
  985. t.currentTest.backtrace = haxe_CallStack.toString(haxe_CallStack.exceptionStack());
  986. }
  987. }
  988. this.result.add(t.currentTest);
  989. t.tearDown();
  990. }
  991. }
  992. haxe_unit_TestRunner.print("\n");
  993. haxe_Log.trace = old;
  994. }
  995. ,__class__: haxe_unit_TestRunner
  996. };
  997. var haxe_unit_TestStatus = function() {
  998. this.done = false;
  999. this.success = false;
  1000. };
  1001. haxe_unit_TestStatus.__name__ = ["haxe","unit","TestStatus"];
  1002. haxe_unit_TestStatus.prototype = {
  1003. done: null
  1004. ,success: null
  1005. ,error: null
  1006. ,method: null
  1007. ,classname: null
  1008. ,posInfos: null
  1009. ,backtrace: null
  1010. ,__class__: haxe_unit_TestStatus
  1011. };
  1012. var js__$Boot_HaxeError = function(val) {
  1013. Error.call(this);
  1014. this.val = val;
  1015. this.message = String(val);
  1016. if(Error.captureStackTrace) Error.captureStackTrace(this,js__$Boot_HaxeError);
  1017. };
  1018. js__$Boot_HaxeError.__name__ = ["js","_Boot","HaxeError"];
  1019. js__$Boot_HaxeError.__super__ = Error;
  1020. js__$Boot_HaxeError.prototype = $extend(Error.prototype,{
  1021. val: null
  1022. ,__class__: js__$Boot_HaxeError
  1023. });
  1024. var js_Boot = function() { };
  1025. js_Boot.__name__ = ["js","Boot"];
  1026. js_Boot.__unhtml = function(s) {
  1027. return s.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
  1028. };
  1029. js_Boot.__trace = function(v,i) {
  1030. var msg = i != null?i.fileName + ":" + i.lineNumber + ": ":"";
  1031. msg += js_Boot.__string_rec(v,"");
  1032. if(i != null && i.customParams != null) {
  1033. var _g = 0;
  1034. var _g1 = i.customParams;
  1035. while(_g < _g1.length) {
  1036. var v1 = _g1[_g];
  1037. ++_g;
  1038. msg += "," + js_Boot.__string_rec(v1,"");
  1039. }
  1040. }
  1041. var d;
  1042. if(typeof(document) != "undefined" && (d = document.getElementById("haxe:trace")) != null) d.innerHTML += js_Boot.__unhtml(msg) + "<br/>"; else if(typeof console != "undefined" && console.log != null) console.log(msg);
  1043. };
  1044. js_Boot.getClass = function(o) {
  1045. if((o instanceof Array) && o.__enum__ == null) return Array; else {
  1046. var cl = o.__class__;
  1047. if(cl != null) return cl;
  1048. var name = js_Boot.__nativeClassName(o);
  1049. if(name != null) return js_Boot.__resolveNativeClass(name);
  1050. return null;
  1051. }
  1052. };
  1053. js_Boot.__string_rec = function(o,s) {
  1054. if(o == null) return "null";
  1055. if(s.length >= 5) return "<...>";
  1056. var t = typeof(o);
  1057. if(t == "function" && (o.__name__ || o.__ename__)) t = "object";
  1058. switch(t) {
  1059. case "object":
  1060. if(o instanceof Array) {
  1061. if(o.__enum__) {
  1062. if(o.length == 2) return o[0];
  1063. var str2 = o[0] + "(";
  1064. s += "\t";
  1065. var _g1 = 2;
  1066. var _g = o.length;
  1067. while(_g1 < _g) {
  1068. var i1 = _g1++;
  1069. if(i1 != 2) str2 += "," + js_Boot.__string_rec(o[i1],s); else str2 += js_Boot.__string_rec(o[i1],s);
  1070. }
  1071. return str2 + ")";
  1072. }
  1073. var l = o.length;
  1074. var i;
  1075. var str1 = "[";
  1076. s += "\t";
  1077. var _g2 = 0;
  1078. while(_g2 < l) {
  1079. var i2 = _g2++;
  1080. str1 += (i2 > 0?",":"") + js_Boot.__string_rec(o[i2],s);
  1081. }
  1082. str1 += "]";
  1083. return str1;
  1084. }
  1085. var tostr;
  1086. try {
  1087. tostr = o.toString;
  1088. } catch( e ) {
  1089. haxe_CallStack.lastException = e;
  1090. if (e instanceof js__$Boot_HaxeError) e = e.val;
  1091. return "???";
  1092. }
  1093. if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
  1094. var s2 = o.toString();
  1095. if(s2 != "[object Object]") return s2;
  1096. }
  1097. var k = null;
  1098. var str = "{\n";
  1099. s += "\t";
  1100. var hasp = o.hasOwnProperty != null;
  1101. for( var k in o ) {
  1102. if(hasp && !o.hasOwnProperty(k)) {
  1103. continue;
  1104. }
  1105. if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
  1106. continue;
  1107. }
  1108. if(str.length != 2) str += ", \n";
  1109. str += s + k + " : " + js_Boot.__string_rec(o[k],s);
  1110. }
  1111. s = s.substring(1);
  1112. str += "\n" + s + "}";
  1113. return str;
  1114. case "function":
  1115. return "<function>";
  1116. case "string":
  1117. return o;
  1118. default:
  1119. return String(o);
  1120. }
  1121. };
  1122. js_Boot.__interfLoop = function(cc,cl) {
  1123. if(cc == null) return false;
  1124. if(cc == cl) return true;
  1125. var intf = cc.__interfaces__;
  1126. if(intf != null) {
  1127. var _g1 = 0;
  1128. var _g = intf.length;
  1129. while(_g1 < _g) {
  1130. var i = _g1++;
  1131. var i1 = intf[i];
  1132. if(i1 == cl || js_Boot.__interfLoop(i1,cl)) return true;
  1133. }
  1134. }
  1135. return js_Boot.__interfLoop(cc.__super__,cl);
  1136. };
  1137. js_Boot.__instanceof = function(o,cl) {
  1138. if(cl == null) return false;
  1139. switch(cl) {
  1140. case Int:
  1141. return (o|0) === o;
  1142. case Float:
  1143. return typeof(o) == "number";
  1144. case Bool:
  1145. return typeof(o) == "boolean";
  1146. case String:
  1147. return typeof(o) == "string";
  1148. case Array:
  1149. return (o instanceof Array) && o.__enum__ == null;
  1150. case Dynamic:
  1151. return true;
  1152. default:
  1153. if(o != null) {
  1154. if(typeof(cl) == "function") {
  1155. if(o instanceof cl) return true;
  1156. if(js_Boot.__interfLoop(js_Boot.getClass(o),cl)) return true;
  1157. } else if(typeof(cl) == "object" && js_Boot.__isNativeObj(cl)) {
  1158. if(o instanceof cl) return true;
  1159. }
  1160. } else return false;
  1161. if(cl == Class && o.__name__ != null) return true;
  1162. if(cl == Enum && o.__ename__ != null) return true;
  1163. return o.__enum__ == cl;
  1164. }
  1165. };
  1166. js_Boot.__nativeClassName = function(o) {
  1167. var name = js_Boot.__toStr.call(o).slice(8,-1);
  1168. if(name == "Object" || name == "Function" || name == "Math" || name == "JSON") return null;
  1169. return name;
  1170. };
  1171. js_Boot.__isNativeObj = function(o) {
  1172. return js_Boot.__nativeClassName(o) != null;
  1173. };
  1174. js_Boot.__resolveNativeClass = function(name) {
  1175. return $global[name];
  1176. };
  1177. var js_Node = function() { };
  1178. js_Node.__name__ = ["js","Node"];
  1179. var pony_ILogable = function() { };
  1180. pony_ILogable.__name__ = ["pony","ILogable"];
  1181. pony_ILogable.prototype = {
  1182. __class__: pony_ILogable
  1183. };
  1184. var pony_magic_HasSignal = function() { };
  1185. pony_magic_HasSignal.__name__ = ["pony","magic","HasSignal"];
  1186. var pony_Logable = function() {
  1187. };
  1188. pony_Logable.__name__ = ["pony","Logable"];
  1189. pony_Logable.__interfaces__ = [pony_magic_HasSignal,pony_ILogable];
  1190. pony_Logable.prototype = {
  1191. error: function(s,p) {
  1192. pony_events__$Event2_Event2_$Impl_$.dispatch(this.eError,s,p);
  1193. }
  1194. ,eLog: null
  1195. ,eError: null
  1196. ,__class__: pony_Logable
  1197. };
  1198. var pony_Priority = function(data,$double,addAfter) {
  1199. if(addAfter == null) addAfter = false;
  1200. if($double == null) $double = false;
  1201. this.addAfter = addAfter;
  1202. this.hash = new haxe_ds_IntMap();
  1203. this.data = [];
  1204. this.counters = [0];
  1205. this["double"] = $double;
  1206. if(data != null) {
  1207. this.data = data;
  1208. this.hash = new haxe_ds_IntMap();
  1209. this.hash.h[0] = this.data.length;
  1210. }
  1211. };
  1212. pony_Priority.__name__ = ["pony","Priority"];
  1213. pony_Priority.__interfaces__ = [pony_magic_HasSignal];
  1214. pony_Priority.prototype = {
  1215. 'double': null
  1216. ,data: null
  1217. ,hash: null
  1218. ,counters: null
  1219. ,addAfter: null
  1220. ,add: function(e,priority) {
  1221. if(priority == null) priority = 0;
  1222. var tmp;
  1223. if(!this["double"]) {
  1224. var tmp1;
  1225. var f = $bind(this,this.compare);
  1226. var a = e;
  1227. tmp1 = function(b) {
  1228. return f(a,b);
  1229. };
  1230. tmp = Lambda.exists(this.data,tmp1);
  1231. } else tmp = false;
  1232. if(tmp) return this;
  1233. var needOnTake = this.data.length == 0;
  1234. var s = this.hash.h.hasOwnProperty(priority)?this.hash.h[priority]:0;
  1235. var c = 0;
  1236. var $it0 = this.hash.keys();
  1237. while( $it0.hasNext() ) {
  1238. var k = $it0.next();
  1239. if(k < priority) c += this.hash.h[k];
  1240. }
  1241. c += s;
  1242. this.data.splice(c,0,e);
  1243. var _g1 = 0;
  1244. var _g = this.counters.length;
  1245. while(_g1 < _g) {
  1246. var k1 = _g1++;
  1247. if(this.addAfter || c < this.counters[k1]) this.counters[k1]++;
  1248. }
  1249. this.hash.h[priority] = s + 1;
  1250. if(needOnTake) pony_events__$Event0_Event0_$Impl_$.dispatch(this.eTake);
  1251. return this;
  1252. }
  1253. ,iterator: function() {
  1254. var _g = this;
  1255. var n = this.counters.push(0) - 1;
  1256. var i = 0;
  1257. return { hasNext : function() {
  1258. if(_g.counters == null) return false;
  1259. if(_g.counters.length < n) _g.counters.push(i);
  1260. if(_g.data.length > _g.counters[n]) return true; else {
  1261. _g.counters.splice(n,1);
  1262. return false;
  1263. }
  1264. }, next : function() {
  1265. return _g.data[_g.counters[n]++];
  1266. }};
  1267. }
  1268. ,compare: function(a,b) {
  1269. return a == b;
  1270. }
  1271. ,asort: function(x,y) {
  1272. return x - y;
  1273. }
  1274. ,remove: function(e) {
  1275. var tmp;
  1276. var f = $bind(this,this.compare);
  1277. var a1 = e;
  1278. tmp = function(b) {
  1279. return f(a1,b);
  1280. };
  1281. var i = pony_ArrayTools.fIndexOf(this.data,tmp);
  1282. if(i == -1) return false;
  1283. var needOnLost = !(this.data.length == 0);
  1284. var _g1 = 0;
  1285. var _g = this.counters.length;
  1286. while(_g1 < _g) {
  1287. var k = _g1++;
  1288. if(i < this.counters[k]) this.counters[k]--;
  1289. }
  1290. this.data.splice(i,1);
  1291. var tmp1;
  1292. var _g2 = [];
  1293. var $it0 = this.hash.keys();
  1294. while( $it0.hasNext() ) {
  1295. var k1 = $it0.next();
  1296. _g2.push(k1);
  1297. }
  1298. tmp1 = _g2;
  1299. var a = tmp1;
  1300. a.sort($bind(this,this.asort));
  1301. var _g11 = 0;
  1302. while(_g11 < a.length) {
  1303. var k2 = a[_g11];
  1304. ++_g11;
  1305. var n = this.hash.h[k2];
  1306. if(i > 0) i -= n; else {
  1307. if(n > 1) this.hash.h[k2] = n - 1; else this.hash.remove(k2);
  1308. break;
  1309. }
  1310. }
  1311. if(needOnLost && this.data.length == 0) pony_events__$Event0_Event0_$Impl_$.dispatch(this.eLost);
  1312. if(this["double"]) this.remove(e);
  1313. return true;
  1314. }
  1315. ,eTake: null
  1316. ,eLost: null
  1317. ,__class__: pony_Priority
  1318. };
  1319. var pony_Queue = function(method) {
  1320. this.busy = false;
  1321. this.method = method;
  1322. this.list = new List();
  1323. this.call = Reflect.makeVarArgs($bind(this,this._call));
  1324. };
  1325. pony_Queue.__name__ = ["pony","Queue"];
  1326. pony_Queue.prototype = {
  1327. list: null
  1328. ,busy: null
  1329. ,call: null
  1330. ,method: null
  1331. ,_call: function(a) {
  1332. if(!this.busy) {
  1333. this.busy = true;
  1334. this.method.apply(null,a);
  1335. } else this.list.add(a);
  1336. }
  1337. ,next: function() {
  1338. if(this.list.length > 0) {
  1339. var args = this.list.pop();
  1340. this.method.apply(null,args);
  1341. } else this.busy = false;
  1342. }
  1343. ,__class__: pony_Queue
  1344. };
  1345. var pony_Tools = function() { };
  1346. pony_Tools.__name__ = ["pony","Tools"];
  1347. pony_Tools.readStr = function(b) {
  1348. try {
  1349. return b.readString(b.readInt32());
  1350. } catch( _ ) {
  1351. haxe_CallStack.lastException = _;
  1352. if (_ instanceof js__$Boot_HaxeError) _ = _.val;
  1353. return null;
  1354. }
  1355. };
  1356. var pony_ArrayTools = function() { };
  1357. pony_ArrayTools.__name__ = ["pony","ArrayTools"];
  1358. pony_ArrayTools.fIndexOf = function(a,f) {
  1359. var i = 0;
  1360. var _g = 0;
  1361. while(_g < a.length) {
  1362. var e = a[_g];
  1363. ++_g;
  1364. if(f(e)) return i;
  1365. i++;
  1366. }
  1367. return -1;
  1368. };
  1369. var pony_events__$Event0_Event0_$Impl_$ = {};
  1370. pony_events__$Event0_Event0_$Impl_$.__name__ = ["pony","events","_Event0","Event0_Impl_"];
  1371. pony_events__$Event0_Event0_$Impl_$.compare = function(a,b) {
  1372. var tmp;
  1373. var _g = a.listener;
  1374. var _g1 = b.listener;
  1375. switch(_g[1]) {
  1376. case 0:
  1377. switch(_g1[1]) {
  1378. case 0:
  1379. tmp = _g[2] == _g1[2];
  1380. break;
  1381. default:
  1382. tmp = false;
  1383. }
  1384. break;
  1385. case 1:
  1386. switch(_g1[1]) {
  1387. case 1:
  1388. tmp = _g[2] == _g1[2];
  1389. break;
  1390. default:
  1391. tmp = false;
  1392. }
  1393. break;
  1394. }
  1395. return tmp;
  1396. };
  1397. pony_events__$Event0_Event0_$Impl_$.dispatch = function(this1,safe) {
  1398. if(safe == null) safe = false;
  1399. if(this1 == null || this1.data == null || safe && this1.counters.length > 1) return false;
  1400. var $it0 = this1.iterator();
  1401. while( $it0.hasNext() ) {
  1402. var e = $it0.next();
  1403. var tmp;
  1404. var _g = e.listener;
  1405. switch(_g[1]) {
  1406. case 0:
  1407. tmp = _g[2]();
  1408. break;
  1409. case 1:
  1410. tmp = pony_events__$Event0_Event0_$Impl_$.dispatch(_g[2],_g[3] || safe);
  1411. break;
  1412. }
  1413. if(tmp) {
  1414. if(this1.counters != null) this1.counters.splice(1,this1.counters.length);
  1415. return true;
  1416. }
  1417. if(!(this1.data == null) && e.once) this1.remove(e);
  1418. }
  1419. return false;
  1420. };
  1421. var pony_events__$Event1_Event1_$Impl_$ = {};
  1422. pony_events__$Event1_Event1_$Impl_$.__name__ = ["pony","events","_Event1","Event1_Impl_"];
  1423. pony_events__$Event1_Event1_$Impl_$.compare = function(a,b) {
  1424. var tmp;
  1425. var _g = a.listener;
  1426. var _g1 = b.listener;
  1427. switch(_g[1]) {
  1428. case 0:
  1429. switch(_g1[1]) {
  1430. case 0:
  1431. tmp = _g[2] == _g1[2];
  1432. break;
  1433. default:
  1434. tmp = false;
  1435. }
  1436. break;
  1437. case 1:
  1438. switch(_g1[1]) {
  1439. case 1:
  1440. tmp = _g[2] == _g1[2];
  1441. break;
  1442. default:
  1443. tmp = false;
  1444. }
  1445. break;
  1446. case 2:
  1447. switch(_g1[1]) {
  1448. case 2:
  1449. tmp = _g[2] == _g1[2];
  1450. break;
  1451. default:
  1452. tmp = false;
  1453. }
  1454. break;
  1455. case 3:
  1456. switch(_g1[1]) {
  1457. case 3:
  1458. tmp = _g[2] == _g1[2];
  1459. break;
  1460. default:
  1461. tmp = false;
  1462. }
  1463. break;
  1464. case 4:
  1465. switch(_g1[1]) {
  1466. case 4:
  1467. tmp = _g[3] == _g1[3];
  1468. break;
  1469. default:
  1470. tmp = false;
  1471. }
  1472. break;
  1473. case 5:
  1474. switch(_g1[1]) {
  1475. case 5:
  1476. tmp = _g[3] == _g1[3];
  1477. break;
  1478. default:
  1479. tmp = false;
  1480. }
  1481. break;
  1482. }
  1483. return tmp;
  1484. };
  1485. pony_events__$Event1_Event1_$Impl_$.dispatch = function(this1,a1,safe) {
  1486. if(safe == null) safe = false;
  1487. if(this1 == null || this1.data == null || safe && this1.counters.length > 1) return false;
  1488. var $it0 = this1.iterator();
  1489. while( $it0.hasNext() ) {
  1490. var e = $it0.next();
  1491. var tmp;
  1492. var _g = e.listener;
  1493. switch(_g[1]) {
  1494. case 0:
  1495. tmp = _g[2]();
  1496. break;
  1497. case 1:
  1498. tmp = _g[2](a1);
  1499. break;
  1500. case 2:
  1501. tmp = pony_events__$Event0_Event0_$Impl_$.dispatch(_g[2],_g[3] || safe);
  1502. break;
  1503. case 3:
  1504. tmp = pony_events__$Event1_Event1_$Impl_$.dispatch(_g[2],a1,_g[3] || safe);
  1505. break;
  1506. case 4:
  1507. if(_g[3] == a1) tmp = pony_events__$Event0_Event0_$Impl_$.dispatch(_g[2],safe); else tmp = false;
  1508. break;
  1509. case 5:
  1510. if(_g[3] != a1) tmp = pony_events__$Event1_Event1_$Impl_$.dispatch(_g[2],a1,safe); else tmp = false;
  1511. break;
  1512. default:
  1513. tmp = false;
  1514. }
  1515. if(tmp) {
  1516. if(this1.counters != null) this1.counters.splice(1,this1.counters.length);
  1517. return true;
  1518. }
  1519. if(!(this1.data == null) && e.once) this1.remove(e);
  1520. }
  1521. return false;
  1522. };
  1523. var pony_events__$Event2_Event2_$Impl_$ = {};
  1524. pony_events__$Event2_Event2_$Impl_$.__name__ = ["pony","events","_Event2","Event2_Impl_"];
  1525. pony_events__$Event2_Event2_$Impl_$.compare = function(a,b) {
  1526. var tmp;
  1527. var _g = a.listener;
  1528. var _g1 = b.listener;
  1529. switch(_g[1]) {
  1530. case 0:
  1531. switch(_g1[1]) {
  1532. case 0:
  1533. tmp = _g[2] == _g1[2];
  1534. break;
  1535. default:
  1536. tmp = false;
  1537. }
  1538. break;
  1539. case 1:
  1540. switch(_g1[1]) {
  1541. case 1:
  1542. tmp = _g[2] == _g1[2];
  1543. break;
  1544. default:
  1545. tmp = false;
  1546. }
  1547. break;
  1548. case 2:
  1549. switch(_g1[1]) {
  1550. case 2:
  1551. tmp = _g[2] == _g1[2];
  1552. break;
  1553. default:
  1554. tmp = false;
  1555. }
  1556. break;
  1557. case 3:
  1558. switch(_g1[1]) {
  1559. case 3:
  1560. tmp = _g[2] == _g1[2];
  1561. break;
  1562. default:
  1563. tmp = false;
  1564. }
  1565. break;
  1566. case 4:
  1567. switch(_g1[1]) {
  1568. case 4:
  1569. tmp = _g[2] == _g1[2];
  1570. break;
  1571. default:
  1572. tmp = false;
  1573. }
  1574. break;
  1575. case 5:
  1576. switch(_g1[1]) {
  1577. case 5:
  1578. tmp = _g[2] == _g1[2];
  1579. break;
  1580. default:
  1581. tmp = false;
  1582. }
  1583. break;
  1584. case 6:
  1585. switch(_g1[1]) {
  1586. case 6:
  1587. if(_g[3] == _g1[3]) tmp = _g[4] == _g1[4]; else tmp = false;
  1588. break;
  1589. default:
  1590. tmp = false;
  1591. }
  1592. break;
  1593. case 7:
  1594. switch(_g1[1]) {
  1595. case 7:
  1596. tmp = _g[3] == _g1[3];
  1597. break;
  1598. default:
  1599. tmp = false;
  1600. }
  1601. break;
  1602. case 8:
  1603. switch(_g1[1]) {
  1604. case 8:
  1605. tmp = _g[3] == _g1[3];
  1606. break;
  1607. default:
  1608. tmp = false;
  1609. }
  1610. break;
  1611. case 9:
  1612. switch(_g1[1]) {
  1613. case 9:
  1614. if(_g[3] == _g1[3]) tmp = _g[4] == _g1[4]; else tmp = false;
  1615. break;
  1616. default:
  1617. tmp = false;
  1618. }
  1619. break;
  1620. case 10:
  1621. switch(_g1[1]) {
  1622. case 10:
  1623. tmp = _g[3] == _g1[3];
  1624. break;
  1625. default:
  1626. tmp = false;
  1627. }
  1628. break;
  1629. case 11:
  1630. switch(_g1[1]) {
  1631. case 11:
  1632. tmp = _g[3] == _g1[3];
  1633. break;
  1634. default:
  1635. tmp = false;
  1636. }
  1637. break;
  1638. }
  1639. return tmp;
  1640. };
  1641. pony_events__$Event2_Event2_$Impl_$.dispatch = function(this1,a1,a2,safe) {
  1642. if(safe == null) safe = false;
  1643. if(this1 == null || this1.data == null || safe && this1.counters.length > 1) return false;
  1644. var $it0 = this1.iterator();
  1645. while( $it0.hasNext() ) {
  1646. var e = $it0.next();
  1647. var tmp;
  1648. var _g = e.listener;
  1649. switch(_g[1]) {
  1650. case 0:
  1651. tmp = _g[2]();
  1652. break;
  1653. case 1:
  1654. tmp = _g[2](a1);
  1655. break;
  1656. case 2:
  1657. tmp = _g[2](a1,a2);
  1658. break;
  1659. case 3:
  1660. tmp = pony_events__$Event0_Event0_$Impl_$.dispatch(_g[2],_g[3] || safe);
  1661. break;
  1662. case 4:
  1663. tmp = pony_events__$Event1_Event1_$Impl_$.dispatch(_g[2],a1,_g[3] || safe);
  1664. break;
  1665. case 5:
  1666. tmp = pony_events__$Event2_Event2_$Impl_$.dispatch(_g[2],a1,a2,_g[3] || safe);
  1667. break;
  1668. case 6:
  1669. if(_g[3] == a1 && _g[4] == a2) tmp = pony_events__$Event0_Event0_$Impl_$.dispatch(_g[2],safe); else tmp = false;
  1670. break;
  1671. case 7:
  1672. if(_g[3] == a1) tmp = pony_events__$Event1_Event1_$Impl_$.dispatch(_g[2],a2,safe); else tmp = false;
  1673. break;
  1674. case 8:
  1675. if(_g[3] == a2) tmp = pony_events__$Event1_Event1_$Impl_$.dispatch(_g[2],a1,safe); else tmp = false;
  1676. break;
  1677. case 9:
  1678. if(_g[3] != a1 && _g[4] != a2) tmp = pony_events__$Event2_Event2_$Impl_$.dispatch(_g[2],a1,a2,safe); else tmp = false;
  1679. break;
  1680. case 10:
  1681. if(_g[3] != a1) tmp = pony_events__$Event2_Event2_$Impl_$.dispatch(_g[2],a1,a2,safe); else tmp = false;
  1682. break;
  1683. case 11:
  1684. if(_g[3] != a2) tmp = pony_events__$Event2_Event2_$Impl_$.dispatch(_g[2],a1,a2,safe); else tmp = false;
  1685. break;
  1686. default:
  1687. tmp = false;
  1688. }
  1689. if(tmp) {
  1690. if(this1.counters != null) this1.counters.splice(1,this1.counters.length);
  1691. return true;
  1692. }
  1693. if(!(this1.data == null) && e.once) this1.remove(e);
  1694. }
  1695. return false;
  1696. };
  1697. var pony_events_Listener0Type = { __ename__ : true, __constructs__ : ["LFunction0","LEvent0"] };
  1698. pony_events_Listener0Type.LFunction0 = function(f) { var $x = ["LFunction0",0,f]; $x.__enum__ = pony_events_Listener0Type; $x.toString = $estr; return $x; };
  1699. pony_events_Listener0Type.LEvent0 = function(s,safe) { var $x = ["LEvent0",1,s,safe]; $x.__enum__ = pony_events_Listener0Type; $x.toString = $estr; return $x; };
  1700. var pony_events_Listener1Type = { __ename__ : true, __constructs__ : ["LFunction0","LFunction1","LEvent0","LEvent1","LSub","LNot"] };
  1701. pony_events_Listener1Type.LFunction0 = function(f) { var $x = ["LFunction0",0,f]; $x.__enum__ = pony_events_Listener1Type; $x.toString = $estr; return $x; };
  1702. pony_events_Listener1Type.LFunction1 = function(f) { var $x = ["LFunction1",1,f]; $x.__enum__ = pony_events_Listener1Type; $x.toString = $estr; return $x; };
  1703. pony_events_Listener1Type.LEvent0 = function(s,safe) { var $x = ["LEvent0",2,s,safe]; $x.__enum__ = pony_events_Listener1Type; $x.toString = $estr; return $x; };
  1704. pony_events_Listener1Type.LEvent1 = function(s,safe) { var $x = ["LEvent1",3,s,safe]; $x.__enum__ = pony_events_Listener1Type; $x.toString = $estr; return $x; };
  1705. pony_events_Listener1Type.LSub = function(s,v) { var $x = ["LSub",4,s,v]; $x.__enum__ = pony_events_Listener1Type; $x.toString = $estr; return $x; };
  1706. pony_events_Listener1Type.LNot = function(s,v) { var $x = ["LNot",5,s,v]; $x.__enum__ = pony_events_Listener1Type; $x.toString = $estr; return $x; };
  1707. var pony_events_Listener2Type = { __ename__ : true, __constructs__ : ["LFunction0","LFunction1","LFunction2","LEvent0","LEvent1","LEvent2","LSub","LSub1","LSub2","LNot","LNot1","LNot2"] };
  1708. pony_events_Listener2Type.LFunction0 = function(f) { var $x = ["LFunction0",0,f]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1709. pony_events_Listener2Type.LFunction1 = function(f) { var $x = ["LFunction1",1,f]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1710. pony_events_Listener2Type.LFunction2 = function(f) { var $x = ["LFunction2",2,f]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1711. pony_events_Listener2Type.LEvent0 = function(s,safe) { var $x = ["LEvent0",3,s,safe]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1712. pony_events_Listener2Type.LEvent1 = function(s,safe) { var $x = ["LEvent1",4,s,safe]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1713. pony_events_Listener2Type.LEvent2 = function(s,safe) { var $x = ["LEvent2",5,s,safe]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1714. pony_events_Listener2Type.LSub = function(s,v1,v2) { var $x = ["LSub",6,s,v1,v2]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1715. pony_events_Listener2Type.LSub1 = function(s,v) { var $x = ["LSub1",7,s,v]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1716. pony_events_Listener2Type.LSub2 = function(s,v) { var $x = ["LSub2",8,s,v]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1717. pony_events_Listener2Type.LNot = function(s,v1,v2) { var $x = ["LNot",9,s,v1,v2]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1718. pony_events_Listener2Type.LNot1 = function(s,v) { var $x = ["LNot1",10,s,v]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1719. pony_events_Listener2Type.LNot2 = function(s,v) { var $x = ["LNot2",11,s,v]; $x.__enum__ = pony_events_Listener2Type; $x.toString = $estr; return $x; };
  1720. var pony_net_INet = function() { };
  1721. pony_net_INet.__name__ = ["pony","net","INet"];
  1722. var pony_net_ISocketClient = function() { };
  1723. pony_net_ISocketClient.__name__ = ["pony","net","ISocketClient"];
  1724. pony_net_ISocketClient.__interfaces__ = [pony_net_INet];
  1725. var pony_net_ISocketServer = function() { };
  1726. pony_net_ISocketServer.__name__ = ["pony","net","ISocketServer"];
  1727. pony_net_ISocketServer.__interfaces__ = [pony_net_INet];
  1728. var pony_net_SocketClientBase = function(host,port,reconnect,tryCount,aIsWithLength,maxSize) {
  1729. if(maxSize == null) maxSize = 1024;
  1730. if(aIsWithLength == null) aIsWithLength = true;
  1731. if(tryCount == null) tryCount = 0;
  1732. if(reconnect == null) reconnect = -1;
  1733. this.eDisconnect = (function($this) {
  1734. var $r;
  1735. var this1;
  1736. this1 = new pony_Priority(null,false,true);
  1737. this1.compare = pony_events__$Event1_Event1_$Impl_$.compare;
  1738. $r = this1;
  1739. return $r;
  1740. }(this));
  1741. this.eClose = (function($this) {
  1742. var $r;
  1743. var this1;
  1744. this1 = new pony_Priority(null,false,true);
  1745. this1.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  1746. $r = this1;
  1747. return $r;
  1748. }(this));
  1749. this.eString = (function($this) {
  1750. var $r;
  1751. var this1;
  1752. this1 = new pony_Priority(null,false,true);
  1753. this1.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  1754. $r = this1;
  1755. return $r;
  1756. }(this));
  1757. this.eData = (function($this) {
  1758. var $r;
  1759. var this1;
  1760. this1 = new pony_Priority(null,false,true);
  1761. this1.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  1762. $r = this1;
  1763. return $r;
  1764. }(this));
  1765. this.tryCounter = 0;
  1766. this.waitBuf = new haxe_io_BytesOutput();
  1767. this.reconnectDelay = -1;
  1768. pony_Logable.call(this);
  1769. if(host == null) host = "127.0.0.1";
  1770. this.host = host;
  1771. this.port = port;
  1772. this.reconnectDelay = reconnect;
  1773. this.tryCount = tryCount;
  1774. this.maxSize = maxSize;
  1775. this.isWithLength = aIsWithLength;
  1776. this.sharedInit();
  1777. this._open();
  1778. };
  1779. pony_net_SocketClientBase.__name__ = ["pony","net","SocketClientBase"];
  1780. pony_net_SocketClientBase.__interfaces__ = [pony_magic_HasSignal];
  1781. pony_net_SocketClientBase.__super__ = pony_Logable;
  1782. pony_net_SocketClientBase.prototype = $extend(pony_Logable.prototype,{
  1783. readLengthSize: null
  1784. ,server: null
  1785. ,opened: null
  1786. ,id: null
  1787. ,host: null
  1788. ,port: null
  1789. ,isWithLength: null
  1790. ,tryCount: null
  1791. ,reconnectDelay: null
  1792. ,maxSize: null
  1793. ,waitNext: null
  1794. ,waitBuf: null
  1795. ,tryCounter: null
  1796. ,readString: function(b) {
  1797. pony_events__$Event2_Event2_$Impl_$.dispatch(this.eString,b.readString(b.totlen),this);
  1798. return true;
  1799. }
  1800. ,sharedInit: function() {
  1801. var _g = this;
  1802. this.readLengthSize = 4;
  1803. this.opened = false;
  1804. this.id = -1;
  1805. var tmp;
  1806. var _this = this.eString;
  1807. if(_this.eTake == null) {
  1808. var tmp1;
  1809. var this2;
  1810. this2 = new pony_Priority(null,false,true);
  1811. this2.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  1812. tmp1 = this2;
  1813. tmp = _this.eTake = tmp1;
  1814. } else tmp = _this.eTake;
  1815. var this1 = tmp;
  1816. var listener = { once : false, listener : pony_events_Listener0Type.LFunction0(function() {
  1817. _g.eData.add({ once : false, listener : pony_events_Listener2Type.LFunction1($bind(_g,_g.readString))},-1);
  1818. })};
  1819. this1.add(listener);
  1820. var tmp2;
  1821. var _this1 = this.eString;
  1822. if(_this1.eLost == null) {
  1823. var tmp3;
  1824. var this4;
  1825. this4 = new pony_Priority(null,false,true);
  1826. this4.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  1827. tmp3 = this4;
  1828. tmp2 = _this1.eLost = tmp3;
  1829. } else tmp2 = _this1.eLost;
  1830. var this3 = tmp2;
  1831. var listener1 = { once : false, listener : pony_events_Listener0Type.LFunction0(function() {
  1832. _g.eData.remove({ once : false, listener : pony_events_Listener2Type.LFunction1($bind(_g,_g.readString))});
  1833. })};
  1834. this3.add(listener1);
  1835. }
  1836. ,tryAgain: function() {
  1837. this.close();
  1838. if(this.reconnectDelay == 0) {
  1839. pony_events__$Event2_Event2_$Impl_$.dispatch(this.eLog,"Reconnect",{ fileName : "SocketClientBase.hx", lineNumber : 107, className : "pony.net.SocketClientBase", methodName : "tryAgain"});
  1840. this._open();
  1841. } else if(this.reconnectDelay > 0) {
  1842. pony_events__$Event2_Event2_$Impl_$.dispatch(this.eLog,"Reconnect after " + this.reconnectDelay + " ms",{ fileName : "SocketClientBase.hx", lineNumber : 112, className : "pony.net.SocketClientBase", methodName : "tryAgain"});
  1843. haxe_Timer.delay($bind(this,this._open),this.reconnectDelay);
  1844. }
  1845. }
  1846. ,badConnection: function() {
  1847. var tmp;
  1848. if(this.eError == null) {
  1849. var tmp1;
  1850. var this2;
  1851. this2 = new pony_Priority(null,false,true);
  1852. this2.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  1853. tmp1 = this2;
  1854. tmp = this.eError = tmp1;
  1855. } else tmp = this.eError;
  1856. var this1 = tmp;
  1857. var listener = { once : false, listener : pony_events_Listener2Type.LFunction0($bind(this,this.badConnection))};
  1858. this1.remove(listener);
  1859. var listener1 = { once : false, listener : pony_events_Listener1Type.LFunction0($bind(this,this.badConnection))};
  1860. this.eDisconnect.remove(listener1);
  1861. pony_events__$Event2_Event2_$Impl_$.dispatch(this.eLog,"Bad connection",{ fileName : "SocketClientBase.hx", lineNumber : 126, className : "pony.net.SocketClientBase", methodName : "badConnection"});
  1862. if(this.opened) pony_events__$Event0_Event0_$Impl_$.dispatch(this.eLostConnection);
  1863. this.tryAgain();
  1864. return true;
  1865. }
  1866. ,close: function() {
  1867. if(!this.opened) return;
  1868. this.opened = false;
  1869. pony_events__$Event1_Event1_$Impl_$.dispatch(this.eDisconnect,this);
  1870. pony_events__$Event0_Event0_$Impl_$.dispatch(this.eClose);
  1871. }
  1872. ,connect: function() {
  1873. this.opened = true;
  1874. pony_events__$Event1_Event1_$Impl_$.dispatch(this.eConnect,this);
  1875. pony_events__$Event0_Event0_$Impl_$.dispatch(this.eOpen);
  1876. }
  1877. ,_open: function() {
  1878. if(this.tryCounter < this.tryCount) {
  1879. this.tryCounter++;
  1880. var tmp;
  1881. if(this.eError == null) {
  1882. var tmp1;
  1883. var this2;
  1884. this2 = new pony_Priority(null,false,true);
  1885. this2.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  1886. tmp1 = this2;
  1887. tmp = this.eError = tmp1;
  1888. } else tmp = this.eError;
  1889. var this1 = tmp;
  1890. var e = { once : false, listener : pony_events_Listener2Type.LFunction0($bind(this,this.badConnection))};
  1891. e.once = true;
  1892. this1.add(e,-100);
  1893. var e1 = { once : false, listener : pony_events_Listener1Type.LFunction0($bind(this,this.badConnection))};
  1894. e1.once = true;
  1895. this.eDisconnect.add(e1,-100);
  1896. }
  1897. this.open();
  1898. }
  1899. ,open: function() {
  1900. var tmp;
  1901. if(this.eError == null) {
  1902. var tmp1;
  1903. var this2;
  1904. this2 = new pony_Priority(null,false,true);
  1905. this2.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  1906. tmp1 = this2;
  1907. tmp = this.eError = tmp1;
  1908. } else tmp = this.eError;
  1909. var this1 = tmp;
  1910. var listener = { once : false, listener : pony_events_Listener2Type.LFunction0($bind(this,this.tryAgain))};
  1911. listener.once = true;
  1912. this1.add(listener,0);
  1913. }
  1914. ,init: function(server,id) {
  1915. var tmp;
  1916. var this1;
  1917. this1 = new pony_Priority(null,false,true);
  1918. this1.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  1919. tmp = this1;
  1920. this.eData = tmp;
  1921. var tmp1;
  1922. var this2;
  1923. this2 = new pony_Priority(null,false,true);
  1924. this2.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  1925. tmp1 = this2;
  1926. this.eString = tmp1;
  1927. var tmp2;
  1928. var this3;
  1929. this3 = new pony_Priority(null,false,true);
  1930. this3.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  1931. tmp2 = this3;
  1932. this.eClose = tmp2;
  1933. var tmp3;
  1934. var this4;
  1935. this4 = new pony_Priority(null,false,true);
  1936. this4.compare = pony_events__$Event1_Event1_$Impl_$.compare;
  1937. tmp3 = this4;
  1938. this.eDisconnect = tmp3;
  1939. var tmp4;
  1940. var this5;
  1941. this5 = new pony_Priority(null,false,true);
  1942. this5.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  1943. tmp4 = this5;
  1944. this.eLostConnection = tmp4;
  1945. var tmp5;
  1946. var this6;
  1947. this6 = new pony_Priority(null,false,true);
  1948. this6.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  1949. tmp5 = this6;
  1950. this.eReconnect = tmp5;
  1951. var tmp6;
  1952. var this7;
  1953. this7 = new pony_Priority(null,false,true);
  1954. this7.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  1955. tmp6 = this7;
  1956. this.eOpen = tmp6;
  1957. var tmp7;
  1958. var this8;
  1959. this8 = new pony_Priority(null,false,true);
  1960. this8.compare = pony_events__$Event1_Event1_$Impl_$.compare;
  1961. tmp7 = this8;
  1962. this.eConnect = tmp7;
  1963. var listener = { once : false, listener : pony_events_Listener2Type.LEvent2(server.eData)};
  1964. this.eData.add(listener);
  1965. var listener1 = { once : false, listener : pony_events_Listener1Type.LEvent1(server.eDisconnect)};
  1966. this.eDisconnect.add(listener1);
  1967. var tmp8;
  1968. if(this.eConnect == null) {
  1969. var tmp9;
  1970. var this10;
  1971. this10 = new pony_Priority(null,false,true);
  1972. this10.compare = pony_events__$Event1_Event1_$Impl_$.compare;
  1973. tmp9 = this10;
  1974. tmp8 = this.eConnect = tmp9;
  1975. } else tmp8 = this.eConnect;
  1976. var this9 = tmp8;
  1977. var listener2 = { once : false, listener : pony_events_Listener1Type.LEvent1(server.eConnect)};
  1978. this9.add(listener2);
  1979. this.sharedInit();
  1980. this.server = server;
  1981. this.maxSize = server.maxSize;
  1982. this.isWithLength = server.isWithLength;
  1983. this.id = id;
  1984. this.waitNext = 0;
  1985. this.waitBuf = new haxe_io_BytesOutput();
  1986. if(!(server.eString.data.length == 0)) {
  1987. var listener3 = { once : false, listener : pony_events_Listener2Type.LEvent2(server.eString)};
  1988. this.eString.add(listener3);
  1989. }
  1990. }
  1991. ,readLength: function(bi) {
  1992. return bi.readInt32();
  1993. }
  1994. ,joinData: function(bi) {
  1995. if(this.server != null) this.isWithLength = this.server.isWithLength;
  1996. if(this.isWithLength) {
  1997. var size = 0;
  1998. var len = 0;
  1999. if(_$UInt_UInt_$Impl_$.gt(this.waitNext,0)) {
  2000. size = this.waitNext;
  2001. len = bi.totlen;
  2002. } else {
  2003. size = this.readLength(bi);
  2004. len = bi.totlen - this.readLengthSize;
  2005. }
  2006. if(_$UInt_UInt_$Impl_$.gt(size,len)) {
  2007. this.waitNext = size - len;
  2008. this.waitBuf.write(bi.read(len));
  2009. } else {
  2010. if(_$UInt_UInt_$Impl_$.gt(this.waitNext,0)) {
  2011. this.waitNext = 0;
  2012. this.waitBuf.write(bi.read(size));
  2013. pony_events__$Event2_Event2_$Impl_$.dispatch(this.eData,new haxe_io_BytesInput(this.waitBuf.getBytes()),this);
  2014. } else pony_events__$Event2_Event2_$Impl_$.dispatch(this.eData,new haxe_io_BytesInput(bi.read(size)),this);
  2015. this.waitBuf = new haxe_io_BytesOutput();
  2016. }
  2017. } else pony_events__$Event2_Event2_$Impl_$.dispatch(this.eData,bi,this);
  2018. }
  2019. ,destroy: function() {
  2020. this.close();
  2021. var this1 = this.eLostConnection;
  2022. if(this1 != null) {
  2023. var needOnLost = !(this1.data.length == 0);
  2024. this1.hash = new haxe_ds_IntMap();
  2025. this1.data = [];
  2026. this1.counters = [0];
  2027. if(needOnLost) pony_events__$Event0_Event0_$Impl_$.dispatch(this1.eLost);
  2028. this1.hash = null;
  2029. this1.data = null;
  2030. this1.counters = null;
  2031. this1.eLost = null;
  2032. this1.eTake = null;
  2033. }
  2034. this.eLostConnection = null;
  2035. var this2 = this.eReconnect;
  2036. if(this2 != null) {
  2037. var needOnLost1 = !(this2.data.length == 0);
  2038. this2.hash = new haxe_ds_IntMap();
  2039. this2.data = [];
  2040. this2.counters = [0];
  2041. if(needOnLost1) pony_events__$Event0_Event0_$Impl_$.dispatch(this2.eLost);
  2042. this2.hash = null;
  2043. this2.data = null;
  2044. this2.counters = null;
  2045. this2.eLost = null;
  2046. this2.eTake = null;
  2047. }
  2048. this.eReconnect = null;
  2049. var this3 = this.eString;
  2050. if(this3 != null) {
  2051. var needOnLost2 = !(this3.data.length == 0);
  2052. this3.hash = new haxe_ds_IntMap();
  2053. this3.data = [];
  2054. this3.counters = [0];
  2055. if(needOnLost2) pony_events__$Event0_Event0_$Impl_$.dispatch(this3.eLost);
  2056. this3.hash = null;
  2057. this3.data = null;
  2058. this3.counters = null;
  2059. this3.eLost = null;
  2060. this3.eTake = null;
  2061. }
  2062. this.eString = null;
  2063. var this4 = this.eData;
  2064. if(this4 != null) {
  2065. var needOnLost3 = !(this4.data.length == 0);
  2066. this4.hash = new haxe_ds_IntMap();
  2067. this4.data = [];
  2068. this4.counters = [0];
  2069. if(needOnLost3) pony_events__$Event0_Event0_$Impl_$.dispatch(this4.eLost);
  2070. this4.hash = null;
  2071. this4.data = null;
  2072. this4.counters = null;
  2073. this4.eLost = null;
  2074. this4.eTake = null;
  2075. }
  2076. this.eData = null;
  2077. var this5 = this.eConnect;
  2078. if(this5 != null) {
  2079. var needOnLost4 = !(this5.data.length == 0);
  2080. this5.hash = new haxe_ds_IntMap();
  2081. this5.data = [];
  2082. this5.counters = [0];
  2083. if(needOnLost4) pony_events__$Event0_Event0_$Impl_$.dispatch(this5.eLost);
  2084. this5.hash = null;
  2085. this5.data = null;
  2086. this5.counters = null;
  2087. this5.eLost = null;
  2088. this5.eTake = null;
  2089. }
  2090. this.eConnect = null;
  2091. var this6 = this.eOpen;
  2092. if(this6 != null) {
  2093. var needOnLost5 = !(this6.data.length == 0);
  2094. this6.hash = new haxe_ds_IntMap();
  2095. this6.data = [];
  2096. this6.counters = [0];
  2097. if(needOnLost5) pony_events__$Event0_Event0_$Impl_$.dispatch(this6.eLost);
  2098. this6.hash = null;
  2099. this6.data = null;
  2100. this6.counters = null;
  2101. this6.eLost = null;
  2102. this6.eTake = null;
  2103. }
  2104. this.eOpen = null;
  2105. var this7 = this.eClose;
  2106. if(this7 != null) {
  2107. var needOnLost6 = !(this7.data.length == 0);
  2108. this7.hash = new haxe_ds_IntMap();
  2109. this7.data = [];
  2110. this7.counters = [0];
  2111. if(needOnLost6) pony_events__$Event0_Event0_$Impl_$.dispatch(this7.eLost);
  2112. this7.hash = null;
  2113. this7.data = null;
  2114. this7.counters = null;
  2115. this7.eLost = null;
  2116. this7.eTake = null;
  2117. }
  2118. this.eClose = null;
  2119. var this8 = this.eDisconnect;
  2120. if(this8 != null) {
  2121. var needOnLost7 = !(this8.data.length == 0);
  2122. this8.hash = new haxe_ds_IntMap();
  2123. this8.data = [];
  2124. this8.counters = [0];
  2125. if(needOnLost7) pony_events__$Event0_Event0_$Impl_$.dispatch(this8.eLost);
  2126. this8.hash = null;
  2127. this8.data = null;
  2128. this8.counters = null;
  2129. this8.eLost = null;
  2130. this8.eTake = null;
  2131. }
  2132. this.eDisconnect = null;
  2133. }
  2134. ,eData: null
  2135. ,eString: null
  2136. ,eClose: null
  2137. ,eDisconnect: null
  2138. ,eLostConnection: null
  2139. ,eReconnect: null
  2140. ,eOpen: null
  2141. ,eConnect: null
  2142. ,__class__: pony_net_SocketClientBase
  2143. });
  2144. var pony_net_nodejs_SocketClient = function(host,port,reconnect,tryCount,aIsWithLength,maxSize) {
  2145. pony_net_SocketClientBase.call(this,host,port,reconnect,tryCount,aIsWithLength,maxSize);
  2146. };
  2147. pony_net_nodejs_SocketClient.__name__ = ["pony","net","nodejs","SocketClient"];
  2148. pony_net_nodejs_SocketClient.__super__ = pony_net_SocketClientBase;
  2149. pony_net_nodejs_SocketClient.prototype = $extend(pony_net_SocketClientBase.prototype,{
  2150. socket: null
  2151. ,q: null
  2152. ,open: function() {
  2153. pony_net_SocketClientBase.prototype.open.call(this);
  2154. this.socket = js_Node.require("net").connect(this.port,this.host);
  2155. this.socket.on("connect",$bind(this,this.connect));
  2156. this.nodejsInit(this.socket);
  2157. }
  2158. ,nodejsInit: function(s) {
  2159. this.q = new pony_Queue($bind(this,this._send));
  2160. this.socket = s;
  2161. s.on("data",$bind(this,this.dataHandler));
  2162. s.on("end",$bind(this,this.close));
  2163. var tmp;
  2164. var f = $bind(this,this.error);
  2165. tmp = function() {
  2166. f("socket error",{ fileName : "SocketClient.hx", lineNumber : 61, className : "pony.net.nodejs.SocketClient", methodName : "nodejsInit"});
  2167. };
  2168. s.on("error",tmp);
  2169. }
  2170. ,close: function() {
  2171. pony_net_SocketClientBase.prototype.close.call(this);
  2172. if(this.socket != null) {
  2173. this.socket.end();
  2174. this.socket.destroy();
  2175. this.socket = null;
  2176. }
  2177. }
  2178. ,send: function(data) {
  2179. this.q.call(data);
  2180. }
  2181. ,_send: function(data) {
  2182. var tmp;
  2183. var _this = data.getBytes();
  2184. tmp = _this.b;
  2185. this.socket.write(tmp,null,($_=this.q,$bind($_,$_.next)));
  2186. }
  2187. ,dataHandler: function(d) {
  2188. this.joinData(new haxe_io_BytesInput(haxe_io_Bytes.ofData(d)));
  2189. }
  2190. ,__class__: pony_net_nodejs_SocketClient
  2191. });
  2192. var pony_net_SocketClient = function(host,port,reconnect,tryCount,aIsWithLength,maxSize) {
  2193. pony_net_nodejs_SocketClient.call(this,host,port,reconnect,tryCount,aIsWithLength,maxSize);
  2194. };
  2195. pony_net_SocketClient.__name__ = ["pony","net","SocketClient"];
  2196. pony_net_SocketClient.__interfaces__ = [pony_net_ISocketClient];
  2197. pony_net_SocketClient.__super__ = pony_net_nodejs_SocketClient;
  2198. pony_net_SocketClient.prototype = $extend(pony_net_nodejs_SocketClient.prototype,{
  2199. writeLengthSize: null
  2200. ,stack: null
  2201. ,sharedInit: function() {
  2202. this.writeLengthSize = 4;
  2203. this.stack = [];
  2204. pony_net_nodejs_SocketClient.prototype.sharedInit.call(this);
  2205. }
  2206. ,writeLength: function(bo,length) {
  2207. bo.writeInt32(length);
  2208. }
  2209. ,send: function(data) {
  2210. if(!this.opened) {
  2211. this.stack.push(data);
  2212. return;
  2213. }
  2214. var len = data.b.b.length;
  2215. var needSplit = this.maxSize != 0 && _$UInt_UInt_$Impl_$.gt(len,this.maxSize);
  2216. if(this.isWithLength || needSplit) {
  2217. var bo = new haxe_io_BytesOutput();
  2218. if(this.isWithLength) this.writeLength(bo,len);
  2219. if(needSplit) {
  2220. if(this.isWithLength && _$UInt_UInt_$Impl_$.gt(this.maxSize,4 + this.writeLengthSize)) this.maxSize = this.maxSize - this.writeLengthSize;
  2221. var b = new haxe_io_BytesInput(data.getBytes());
  2222. while(_$UInt_UInt_$Impl_$.gte(len,this.maxSize)) {
  2223. bo.write(b.read(this.maxSize));
  2224. len = len - this.maxSize;
  2225. }
  2226. if(_$UInt_UInt_$Impl_$.gt(len,0)) bo.write(b.read(len));
  2227. } else bo.write(data.getBytes());
  2228. pony_net_nodejs_SocketClient.prototype.send.call(this,bo);
  2229. } else pony_net_nodejs_SocketClient.prototype.send.call(this,data);
  2230. }
  2231. ,__class__: pony_net_SocketClient
  2232. });
  2233. var pony_net_SocketServerBase = function() {
  2234. this.eDisconnect = (function($this) {
  2235. var $r;
  2236. var this1;
  2237. this1 = new pony_Priority(null,false,true);
  2238. this1.compare = pony_events__$Event1_Event1_$Impl_$.compare;
  2239. $r = this1;
  2240. return $r;
  2241. }(this));
  2242. this.eClose = (function($this) {
  2243. var $r;
  2244. var this1;
  2245. this1 = new pony_Priority(null,false,true);
  2246. this1.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  2247. $r = this1;
  2248. return $r;
  2249. }(this));
  2250. this.eOpen = (function($this) {
  2251. var $r;
  2252. var this1;
  2253. this1 = new pony_Priority(null,false,true);
  2254. this1.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  2255. $r = this1;
  2256. return $r;
  2257. }(this));
  2258. this.eConnect = (function($this) {
  2259. var $r;
  2260. var this1;
  2261. this1 = new pony_Priority(null,false,true);
  2262. this1.compare = pony_events__$Event1_Event1_$Impl_$.compare;
  2263. $r = this1;
  2264. return $r;
  2265. }(this));
  2266. this.eString = (function($this) {
  2267. var $r;
  2268. var this1;
  2269. this1 = new pony_Priority(null,false,true);
  2270. this1.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  2271. $r = this1;
  2272. return $r;
  2273. }(this));
  2274. this.eData = (function($this) {
  2275. var $r;
  2276. var this1;
  2277. this1 = new pony_Priority(null,false,true);
  2278. this1.compare = pony_events__$Event2_Event2_$Impl_$.compare;
  2279. $r = this1;
  2280. return $r;
  2281. }(this));
  2282. this.isAbleToSend = false;
  2283. this.isWithLength = true;
  2284. this.clients = [];
  2285. var _g = this;
  2286. pony_Logable.call(this);
  2287. var tmp;
  2288. var _this = this.eString;
  2289. if(_this.eTake == null) {
  2290. var tmp1;
  2291. var this2;
  2292. this2 = new pony_Priority(null,false,true);
  2293. this2.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  2294. tmp1 = this2;
  2295. tmp = _this.eTake = tmp1;
  2296. } else tmp = _this.eTake;
  2297. var this1 = tmp;
  2298. var listener = { once : false, listener : pony_events_Listener0Type.LFunction0($bind(this,this.beginString))};
  2299. this1.add(listener);
  2300. var tmp2;
  2301. var _this1 = this.eString;
  2302. if(_this1.eLost == null) {
  2303. var tmp3;
  2304. var this4;
  2305. this4 = new pony_Priority(null,false,true);
  2306. this4.compare = pony_events__$Event0_Event0_$Impl_$.compare;
  2307. tmp3 = this4;
  2308. tmp2 = _this1.eLost = tmp3;
  2309. } else tmp2 = _this1.eLost;
  2310. var this3 = tmp2;
  2311. var listener1 = { once : false, listener : pony_events_Listener0Type.LFunction0($bind(this,this.endString))};
  2312. this3.add(listener1);
  2313. this.clients = [];
  2314. var listener2 = { once : false, listener : pony_events_Listener1Type.LFunction1($bind(this,this.removeClient))};
  2315. this.eDisconnect.add(listener2);
  2316. var e = { once : false, listener : pony_events_Listener0Type.LFunction0(function() {
  2317. _g.opened = true;
  2318. })};
  2319. e.once = true;
  2320. this.eOpen.add(e,0);
  2321. var listener3 = { once : false, listener : pony_events_Listener1Type.LFunction0(function() {
  2322. _g.isAbleToSend = true;
  2323. })};
  2324. listener3.once = true;
  2325. this.eConnect.add(listener3,0);
  2326. };
  2327. pony_net_SocketServerBase.__name__ = ["pony","net","SocketServerBase"];
  2328. pony_net_SocketServerBase.__super__ = pony_Logable;
  2329. pony_net_SocketServerBase.prototype = $extend(pony_Logable.prototype,{
  2330. opened: null
  2331. ,clients: null
  2332. ,isWithLength: null
  2333. ,isAbleToSend: null
  2334. ,maxSize: null
  2335. ,beginString: function() {
  2336. var _g = 0;
  2337. var _g1 = this.clients;
  2338. while(_g < _g1.length) {
  2339. var c = _g1[_g];
  2340. ++_g;
  2341. var listener = { once : false, listener : pony_events_Listener2Type.LEvent2(this.eString)};
  2342. c.eString.add(listener);
  2343. }
  2344. }
  2345. ,endString: function() {
  2346. var _g = 0;
  2347. var _g1 = this.clients;
  2348. while(_g < _g1.length) {
  2349. var c = _g1[_g];
  2350. ++_g;
  2351. var listener = { once : false, listener : pony_events_Listener2Type.LEvent2(this.eString)};
  2352. c.eString.remove(listener);
  2353. }
  2354. }
  2355. ,addClient: function() {
  2356. var cl = Type.createEmptyInstance(pony_net_SocketClient);
  2357. cl.isWithLength = this.isWithLength;
  2358. cl.init(this,this.clients.length);
  2359. this.clients.push(cl);
  2360. return cl;
  2361. }
  2362. ,removeClient: function(cl) {
  2363. HxOverrides.remove(this.clients,cl);
  2364. }
  2365. ,destroy: function() {
  2366. this.opened = false;
  2367. pony_events__$Event0_Event0_$Impl_$.dispatch(this.eClose);
  2368. var this1 = this.eString;
  2369. if(this1 != null) {
  2370. var needOnLost = !(this1.data.length == 0);
  2371. this1.hash = new haxe_ds_IntMap();
  2372. this1.data = [];
  2373. this1.counters = [0];
  2374. if(needOnLost) pony_events__$Event0_Event0_$Impl_$.dispatch(this1.eLost);
  2375. this1.hash = null;
  2376. this1.data = null;
  2377. this1.counters = null;
  2378. this1.eLost = null;
  2379. this1.eTake = null;
  2380. }
  2381. this.eString = null;
  2382. var this2 = this.eData;
  2383. if(this2 != null) {
  2384. var needOnLost1 = !(this2.data.length == 0);
  2385. this2.hash = new haxe_ds_IntMap();
  2386. this2.data = [];
  2387. this2.counters = [0];
  2388. if(needOnLost1) pony_events__$Event0_Event0_$Impl_$.dispatch(this2.eLost);
  2389. this2.hash = null;
  2390. this2.data = null;
  2391. this2.counters = null;
  2392. this2.eLost = null;
  2393. this2.eTake = null;
  2394. }
  2395. this.eData = null;
  2396. var this3 = this.eConnect;
  2397. if(this3 != null) {
  2398. var needOnLost2 = !(this3.data.length == 0);
  2399. this3.hash = new haxe_ds_IntMap();
  2400. this3.data = [];
  2401. this3.counters = [0];
  2402. if(needOnLost2) pony_events__$Event0_Event0_$Impl_$.dispatch(this3.eLost);
  2403. this3.hash = null;
  2404. this3.data = null;
  2405. this3.counters = null;
  2406. this3.eLost = null;
  2407. this3.eTake = null;
  2408. }
  2409. this.eConnect = null;
  2410. var this4 = this.eOpen;
  2411. if(this4 != null) {
  2412. var needOnLost3 = !(this4.data.length == 0);
  2413. this4.hash = new haxe_ds_IntMap();
  2414. this4.data = [];
  2415. this4.counters = [0];
  2416. if(needOnLost3) pony_events__$Event0_Event0_$Impl_$.dispatch(this4.eLost);
  2417. this4.hash = null;
  2418. this4.data = null;
  2419. this4.counters = null;
  2420. this4.eLost = null;
  2421. this4.eTake = null;
  2422. }
  2423. this.eOpen = null;
  2424. var this5 = this.eClose;
  2425. if(this5 != null) {
  2426. var needOnLost4 = !(this5.data.length == 0);
  2427. this5.hash = new haxe_ds_IntMap();
  2428. this5.data = [];
  2429. this5.counters = [0];
  2430. if(needOnLost4) pony_events__$Event0_Event0_$Impl_$.dispatch(this5.eLost);
  2431. this5.hash = null;
  2432. this5.data = null;
  2433. this5.counters = null;
  2434. this5.eLost = null;
  2435. this5.eTake = null;
  2436. }
  2437. this.eClose = null;
  2438. var this6 = this.eDisconnect;
  2439. if(this6 != null) {
  2440. var needOnLost5 = !(this6.data.length == 0);
  2441. this6.hash = new haxe_ds_IntMap();
  2442. this6.data = [];
  2443. this6.counters = [0];
  2444. if(needOnLost5) pony_events__$Event0_Event0_$Impl_$.dispatch(this6.eLost);
  2445. this6.hash = null;
  2446. this6.data = null;
  2447. this6.counters = null;
  2448. this6.eLost = null;
  2449. this6.eTake = null;
  2450. }
  2451. this.eDisconnect = null;
  2452. }
  2453. ,eData: null
  2454. ,eString: null
  2455. ,eConnect: null
  2456. ,eOpen: null
  2457. ,eClose: null
  2458. ,eDisconnect: null
  2459. ,__class__: pony_net_SocketServerBase
  2460. });
  2461. var pony_net_nodejs_SocketServer = function(port) {
  2462. pony_net_SocketServerBase.call(this);
  2463. this.server = js_Node.require("net").createServer(null,null);
  2464. this.server.on("connection",$bind(this,this.connectionHandler));
  2465. var tmp;
  2466. var tmp1;
  2467. var _e = this.eOpen;
  2468. tmp1 = function(safe) {
  2469. return pony_events__$Event0_Event0_$Impl_$.dispatch(_e,safe);
  2470. };
  2471. var f = tmp1;
  2472. tmp = function() {
  2473. return f(false);
  2474. };
  2475. this.server.listen(port,null,tmp);
  2476. };
  2477. pony_net_nodejs_SocketServer.__name__ = ["pony","net","nodejs","SocketServer"];
  2478. pony_net_nodejs_SocketServer.__super__ = pony_net_SocketServerBase;
  2479. pony_net_nodejs_SocketServer.prototype = $extend(pony_net_SocketServerBase.prototype,{
  2480. server: null
  2481. ,connectionHandler: function(c) {
  2482. var cl = this.addClient();
  2483. cl.nodejsInit(c);
  2484. cl.connect();
  2485. }
  2486. ,destroy: function() {
  2487. pony_net_SocketServerBase.prototype.destroy.call(this);
  2488. this.server.close(null);
  2489. this.server = null;
  2490. }
  2491. ,__class__: pony_net_nodejs_SocketServer
  2492. });
  2493. var pony_net_SocketServer = function(port,isWithLength,maxSize) {
  2494. if(maxSize == null) maxSize = 1024;
  2495. if(isWithLength == null) isWithLength = true;
  2496. this.isWithLength = isWithLength;
  2497. this.maxSize = maxSize;
  2498. pony_net_nodejs_SocketServer.call(this,port);
  2499. };
  2500. pony_net_SocketServer.__name__ = ["pony","net","SocketServer"];
  2501. pony_net_SocketServer.__interfaces__ = [pony_net_ISocketServer];
  2502. pony_net_SocketServer.__super__ = pony_net_nodejs_SocketServer;
  2503. pony_net_SocketServer.prototype = $extend(pony_net_nodejs_SocketServer.prototype,{
  2504. destroy: function() {
  2505. if(this.opened) pony_net_nodejs_SocketServer.prototype.destroy.call(this); else if(this.eOpen != null) {
  2506. var listener = { once : false, listener : pony_events_Listener0Type.LFunction0($bind(this,this.destroy))};
  2507. this.eOpen.add(listener);
  2508. }
  2509. }
  2510. ,__class__: pony_net_SocketServer
  2511. });
  2512. var pony_tests_AsyncTests = function() {
  2513. haxe_unit_TestCase.call(this);
  2514. };
  2515. pony_tests_AsyncTests.__name__ = ["pony","tests","AsyncTests"];
  2516. pony_tests_AsyncTests.init = function(count) {
  2517. if(pony_tests_AsyncTests.testCount != 0) throw new js__$Boot_HaxeError("Second init");
  2518. haxe_Log.trace("" + pony_tests_AsyncTests.dec + " Begin tests (" + count + ") " + pony_tests_AsyncTests.dec,{ fileName : "AsyncTests.hx", lineNumber : 58, className : "pony.tests.AsyncTests", methodName : "init"});
  2519. pony_tests_AsyncTests.testCount = count;
  2520. var tmp;
  2521. var _g = new haxe_ds_IntMap();
  2522. var _g1 = 0;
  2523. while(_g1 < count) {
  2524. var i = _g1++;
  2525. _g.h[i] = false;
  2526. }
  2527. tmp = _g;
  2528. pony_tests_AsyncTests.isRead = tmp;
  2529. };
  2530. pony_tests_AsyncTests.equals = function(a,b,infos) {
  2531. pony_tests_AsyncTests.assertList.push({ a : a, b : b, pos : infos});
  2532. };
  2533. pony_tests_AsyncTests.setFlag = function(n,infos) {
  2534. if(n >= pony_tests_AsyncTests.testCount || n < 0) throw new js__$Boot_HaxeError("Wrong test number");
  2535. if(pony_tests_AsyncTests.isRead.h[n]) throw new js__$Boot_HaxeError("Double complite");
  2536. haxe_Log.trace("" + pony_tests_AsyncTests.dec + " Test #" + n + " finished " + pony_tests_AsyncTests.dec,infos);
  2537. pony_tests_AsyncTests.isRead.h[n] = true;
  2538. true;
  2539. if(pony_tests_AsyncTests.lock) {
  2540. haxe_Log.trace("Locked call",{ fileName : "AsyncTests.hx", lineNumber : 79, className : "pony.tests.AsyncTests", methodName : "setFlag"});
  2541. return;
  2542. }
  2543. pony_tests_AsyncTests.lock = true;
  2544. pony_tests_AsyncTests.checkWaitList();
  2545. var $it0 = pony_tests_AsyncTests.isRead.iterator();
  2546. while( $it0.hasNext() ) {
  2547. var e = $it0.next();
  2548. if(!e) {
  2549. pony_tests_AsyncTests.lock = false;
  2550. return;
  2551. }
  2552. }
  2553. var test = new haxe_unit_TestRunner();
  2554. test.add(new pony_tests_AsyncTests());
  2555. test.run();
  2556. };
  2557. pony_tests_AsyncTests.finish = function(infos) {
  2558. if(!pony_tests_AsyncTests.complite) {
  2559. var tmp;
  2560. var a = [];
  2561. var $it0 = pony_tests_AsyncTests.isRead.keys();
  2562. while( $it0.hasNext() ) {
  2563. var k = $it0.next();
  2564. if(!pony_tests_AsyncTests.isRead.h[k]) a.push(k);
  2565. }
  2566. tmp = a;
  2567. throw new js__$Boot_HaxeError("Tests not complited: " + Std.string(tmp));
  2568. }
  2569. haxe_Log.trace("" + pony_tests_AsyncTests.dec + " All tests finished " + pony_tests_AsyncTests.dec,infos);
  2570. };
  2571. pony_tests_AsyncTests.wait = function(it,cb) {
  2572. if(pony_tests_AsyncTests.checkWait(it)) cb(); else pony_tests_AsyncTests.waitList.push({ it : it, cb : cb});
  2573. };
  2574. pony_tests_AsyncTests.checkWait = function(it) {
  2575. var _g1 = Reflect.field(it,"min");
  2576. var _g = Reflect.field(it,"max");
  2577. while(_g1 < _g) {
  2578. var i = _g1++;
  2579. if(!pony_tests_AsyncTests.isRead.h[i]) return false;
  2580. }
  2581. return true;
  2582. };
  2583. pony_tests_AsyncTests.checkWaitList = function() {
  2584. var _g_head = pony_tests_AsyncTests.waitList.h;
  2585. var _g_val = null;
  2586. while(_g_head != null) {
  2587. var tmp;
  2588. _g_val = _g_head[0];
  2589. _g_head = _g_head[1];
  2590. tmp = _g_val;
  2591. var e = tmp;
  2592. if(pony_tests_AsyncTests.checkWait(e.it)) {
  2593. e.cb();
  2594. pony_tests_AsyncTests.waitList.remove(e);
  2595. }
  2596. }
  2597. };
  2598. pony_tests_AsyncTests.__super__ = haxe_unit_TestCase;
  2599. pony_tests_AsyncTests.prototype = $extend(haxe_unit_TestCase.prototype,{
  2600. testRun: function() {
  2601. var _g_head = pony_tests_AsyncTests.assertList.h;
  2602. var _g_val = null;
  2603. while(_g_head != null) {
  2604. var tmp;
  2605. _g_val = _g_head[0];
  2606. _g_head = _g_head[1];
  2607. tmp = _g_val;
  2608. var e = tmp;
  2609. this.assertEquals(e.a,e.b,e.pos);
  2610. }
  2611. pony_tests_AsyncTests.complite = true;
  2612. }
  2613. ,__class__: pony_tests_AsyncTests
  2614. });
  2615. function $iterator(o) { if( o instanceof Array ) return function() { return HxOverrides.iter(o); }; return typeof(o.iterator) == 'function' ? $bind(o,o.iterator) : o.iterator; }
  2616. var $_, $fid = 0;
  2617. function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = function(){ return f.method.apply(f.scope, arguments); }; f.scope = o; f.method = m; o.hx__closures__[m.__id__] = f; } return f; }
  2618. if(Array.prototype.indexOf) HxOverrides.indexOf = function(a,o,i) {
  2619. return Array.prototype.indexOf.call(a,o,i);
  2620. };
  2621. String.prototype.__class__ = String;
  2622. String.__name__ = ["String"];
  2623. Array.__name__ = ["Array"];
  2624. var Int = { __name__ : ["Int"]};
  2625. var Dynamic = { __name__ : ["Dynamic"]};
  2626. var Float = Number;
  2627. Float.__name__ = ["Float"];
  2628. var Bool = Boolean;
  2629. Bool.__ename__ = ["Bool"];
  2630. var Class = { __name__ : ["Class"]};
  2631. var Enum = { };
  2632. Main.testCount = 400;
  2633. Main.delay = 1;
  2634. Main.port = 16003;
  2635. Main.partCount = Main.testCount / 4 | 0;
  2636. Main.blockCount = Main.testCount / 2 | 0;
  2637. Main.finish = false;
  2638. js_Boot.__toStr = {}.toString;
  2639. js_Node.require = require;
  2640. pony_tests_AsyncTests.assertList = new List();
  2641. pony_tests_AsyncTests.testCount = 0;
  2642. pony_tests_AsyncTests.complite = false;
  2643. pony_tests_AsyncTests.dec = "----------";
  2644. pony_tests_AsyncTests.waitList = new List();
  2645. pony_tests_AsyncTests.counter = 0;
  2646. Main.main();
  2647. })(typeof console != "undefined" ? console : {log:function(){}}, typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this);
  2648. //# sourceMappingURL=main.js.map