socket.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. var __reflect = (this && this.__reflect) || function (p, c, t) {
  2. p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t;
  3. };
  4. var __extends = this && this.__extends || function __extends(t, e) {
  5. function r() {
  6. this.constructor = t;
  7. }
  8. for (var i in e) e.hasOwnProperty(i) && (t[i] = e[i]);
  9. r.prototype = e.prototype, t.prototype = new r();
  10. };
  11. //////////////////////////////////////////////////////////////////////////////////////
  12. //
  13. // Copyright (c) 2014-present, Egret Technology.
  14. // All rights reserved.
  15. // Redistribution and use in source and binary forms, with or without
  16. // modification, are permitted provided that the following conditions are met:
  17. //
  18. // * Redistributions of source code must retain the above copyright
  19. // notice, this list of conditions and the following disclaimer.
  20. // * Redistributions in binary form must reproduce the above copyright
  21. // notice, this list of conditions and the following disclaimer in the
  22. // documentation and/or other materials provided with the distribution.
  23. // * Neither the name of the Egret nor the
  24. // names of its contributors may be used to endorse or promote products
  25. // derived from this software without specific prior written permission.
  26. //
  27. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  28. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  29. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  30. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  31. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  32. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  33. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  34. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  35. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  36. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. //
  38. //////////////////////////////////////////////////////////////////////////////////////
  39. var egret;
  40. (function (egret) {
  41. })(egret || (egret = {}));
  42. //////////////////////////////////////////////////////////////////////////////////////
  43. //
  44. // Copyright (c) 2014-present, Egret Technology.
  45. // All rights reserved.
  46. // Redistribution and use in source and binary forms, with or without
  47. // modification, are permitted provided that the following conditions are met:
  48. //
  49. // * Redistributions of source code must retain the above copyright
  50. // notice, this list of conditions and the following disclaimer.
  51. // * Redistributions in binary form must reproduce the above copyright
  52. // notice, this list of conditions and the following disclaimer in the
  53. // documentation and/or other materials provided with the distribution.
  54. // * Neither the name of the Egret nor the
  55. // names of its contributors may be used to endorse or promote products
  56. // derived from this software without specific prior written permission.
  57. //
  58. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  59. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  60. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  61. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  62. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  63. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  64. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  65. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  66. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  67. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  68. //
  69. //////////////////////////////////////////////////////////////////////////////////////
  70. var egret;
  71. (function (egret) {
  72. /**
  73. * The egret.WebSocket class enables code to establish a TCP socket connection, for sending and receiving character string or binary data.
  74. * To use the methods of the egret.WebSocket class, first use the constructor function new egret.WebSocket to create an egret.WebSocket object.
  75. * The socket transmits and receives data in asynchronous mode.
  76. * @event egret.Event.CONNECT Successfully connect to the server。
  77. * @event egret.ProgressEvent.SOCKET_DATA Receiving server data。
  78. * @event egret.Event.CLOSE Dispatched when the server closes the connection.
  79. * @event egret.ProgressEvent Dispatched when an IO error causes a send or load operation to fail.
  80. * @see http://edn.egret.com/cn/docs/page/602 WebSocket
  81. * @version Egret 2.4
  82. * @platform Web,Native
  83. * @includeExample extension/socket/WebSocket.ts
  84. * @language en_US
  85. */
  86. /**
  87. * egret.WebSocket 类启用代码以建立传输控制协议 (TCP) 套接字连接,用于发送和接收字符串或二进制数据。
  88. * 要使用 egret.WebSocket 类的方法,请先使用构造函数 new egret.WebSocket 创建一个 egret.WebSocket 对象。
  89. * 套接字以异步方式传输和接收数据。
  90. * @event egret.Event.CONNECT 连接服务器成功。
  91. * @event egret.ProgressEvent.SOCKET_DATA 接收服务器数据。
  92. * @event egret.Event.CLOSE 在服务器关闭连接时调度。
  93. * @event egret.IOErrorEvent.IO_ERROR 在出现输入/输出错误并导致发送或加载操作失败时调度。。
  94. * @see http://edn.egret.com/cn/docs/page/602 WebSocket
  95. * @version Egret 2.4
  96. * @platform Web,Native
  97. * @includeExample extension/socket/WebSocket.ts
  98. * @language zh_CN
  99. */
  100. var WebSocket = (function (_super) {
  101. __extends(WebSocket, _super);
  102. /**
  103. * Create an egret.WebSocket object
  104. * This parameter is reserved for later versions. The connection address and port number are imported in the connect function
  105. * @version Egret 2.4
  106. * @platform Web,Native
  107. * @language en_US
  108. */
  109. /**
  110. * 创建一个 egret.WebSocket 对象
  111. * 参数为预留参数,现版本暂不处理,连接地址和端口号在 connect 函数中传入
  112. * @version Egret 2.4
  113. * @platform Web,Native
  114. * @language zh_CN
  115. */
  116. function WebSocket(host, port) {
  117. if (host === void 0) { host = ""; }
  118. if (port === void 0) { port = 0; }
  119. var _this = _super.call(this) || this;
  120. /**
  121. * @private
  122. */
  123. _this._writeMessage = "";
  124. /**
  125. * @private
  126. */
  127. _this._readMessage = "";
  128. /**
  129. * @private
  130. */
  131. _this._connected = false;
  132. /**
  133. * @private
  134. */
  135. _this._connecting = false;
  136. /**
  137. * @private
  138. */
  139. _this._isReadySend = false;
  140. /**
  141. * @private
  142. */
  143. _this._bytesWrite = false;
  144. /**
  145. * @private
  146. */
  147. _this._type = WebSocket.TYPE_STRING;
  148. _this._connected = false;
  149. _this._writeMessage = "";
  150. _this._readMessage = "";
  151. _this.socket = new egret.ISocket();
  152. _this.socket.addCallBacks(_this.onConnect, _this.onClose, _this.onSocketData, _this.onError, _this);
  153. return _this;
  154. }
  155. /**
  156. * Connect the socket to the specified host and port number
  157. * @param host Name or IP address of the host to be connected
  158. * @param port Port number to be connected
  159. * @version Egret 2.4
  160. * @platform Web,Native
  161. * @language en_US
  162. */
  163. /**
  164. * 将套接字连接到指定的主机和端口
  165. * @param host 要连接到的主机的名称或 IP 地址
  166. * @param port 要连接到的端口号
  167. * @version Egret 2.4
  168. * @platform Web,Native
  169. * @language zh_CN
  170. */
  171. WebSocket.prototype.connect = function (host, port) {
  172. if (!this._connecting && !this._connected) {
  173. this._connecting = true;
  174. this.socket.connect(host, port);
  175. }
  176. };
  177. /**
  178. * 根据提供的url连接
  179. * @param url 全地址。如ws://echo.websocket.org:80
  180. */
  181. WebSocket.prototype.connectByUrl = function (url) {
  182. if (!this._connecting && !this._connected) {
  183. this._connecting = true;
  184. this.socket.connectByUrl(url);
  185. }
  186. };
  187. /**
  188. * Closesocket
  189. * @version Egret 2.4
  190. * @platform Web,Native
  191. * @language en_US
  192. */
  193. /**
  194. * 关闭套接字
  195. * @version Egret 2.4
  196. * @platform Web,Native
  197. * @language zh_CN
  198. */
  199. WebSocket.prototype.close = function () {
  200. if (this._connected) {
  201. this.socket.close();
  202. }
  203. };
  204. /**
  205. * @private
  206. *
  207. */
  208. WebSocket.prototype.onConnect = function () {
  209. this._connected = true;
  210. this._connecting = false;
  211. this.dispatchEventWith(egret.Event.CONNECT);
  212. };
  213. /**
  214. * @private
  215. *
  216. */
  217. WebSocket.prototype.onClose = function () {
  218. this._connected = false;
  219. this.dispatchEventWith(egret.Event.CLOSE);
  220. };
  221. /**
  222. * @private
  223. *
  224. */
  225. WebSocket.prototype.onError = function () {
  226. if (this._connecting) {
  227. this._connecting = false;
  228. }
  229. this.dispatchEventWith(egret.IOErrorEvent.IO_ERROR);
  230. };
  231. /**
  232. * @private
  233. *
  234. * @param message
  235. */
  236. WebSocket.prototype.onSocketData = function (message) {
  237. if (typeof message == "string") {
  238. this._readMessage += message;
  239. }
  240. else {
  241. this._readByte._writeUint8Array(new Uint8Array(message));
  242. }
  243. egret.ProgressEvent.dispatchProgressEvent(this, egret.ProgressEvent.SOCKET_DATA);
  244. };
  245. /**
  246. * Refresh all data accumulated in the output buffer area of the socket
  247. * @version Egret 2.4
  248. * @platform Web,Native
  249. * @language en_US
  250. */
  251. /**
  252. * 对套接字输出缓冲区中积累的所有数据进行刷新
  253. * @version Egret 2.4
  254. * @platform Web,Native
  255. * @language zh_CN
  256. */
  257. WebSocket.prototype.flush = function () {
  258. if (!this._connected) {
  259. egret.$warn(3101);
  260. return;
  261. }
  262. if (this._writeMessage) {
  263. this.socket.send(this._writeMessage);
  264. this._writeMessage = "";
  265. }
  266. if (this._bytesWrite) {
  267. this.socket.send(this._writeByte.buffer);
  268. this._bytesWrite = false;
  269. this._writeByte.clear();
  270. }
  271. this._isReadySend = false;
  272. };
  273. /**
  274. * Write data in character string in the socket
  275. * @param message The character string to be written in the socket
  276. * @version Egret 2.4
  277. * @platform Web,Native
  278. * @language en_US
  279. */
  280. /**
  281. * 将字符串数据写入套接字
  282. * @param message 要写入套接字的字符串
  283. * @version Egret 2.4
  284. * @platform Web,Native
  285. * @language zh_CN
  286. */
  287. WebSocket.prototype.writeUTF = function (message) {
  288. if (!this._connected) {
  289. egret.$warn(3101);
  290. return;
  291. }
  292. if (this._type == WebSocket.TYPE_BINARY) {
  293. this._bytesWrite = true;
  294. this._writeByte.writeUTF(message);
  295. }
  296. else {
  297. this._writeMessage += message;
  298. }
  299. this.flush();
  300. // return;
  301. // if (this._isReadySend) {
  302. // return;
  303. // }
  304. // this._isReadySend = true;
  305. // egret.callLater(this.flush, this);
  306. };
  307. /**
  308. * Read a UTF-8 character string from the socket
  309. * @returns {string}
  310. * @version Egret 2.4
  311. * @platform Web,Native
  312. * @language en_US
  313. */
  314. /**
  315. * 从套接字读取一个 UTF-8 字符串
  316. * @returns {string}
  317. * @version Egret 2.4
  318. * @platform Web,Native
  319. * @language zh_CN
  320. */
  321. WebSocket.prototype.readUTF = function () {
  322. var message;
  323. if (this._type == WebSocket.TYPE_BINARY) {
  324. this._readByte.position = 0;
  325. message = this._readByte.readUTF();
  326. this._readByte.clear();
  327. }
  328. else {
  329. message = this._readMessage;
  330. this._readMessage = "";
  331. }
  332. return message;
  333. };
  334. /**
  335. * Write a series of bytes from the specified byte array. The writing operation starts from the location expressed by offset.
  336. * If the length parameter is ignored, the default length 0 indicates that data is written from offset in the entire buffer area.
  337. * If the offset parameter is ignored, data is written in the entire buffer area.
  338. * @param bytes The ByteArray object where data is read from
  339. * @param offset Zero-based offset in the ByteArray object. From here start performing data writing
  340. * @param length Number of bytes to be written Default value 0 indicates data is written in the entire buffer area from the value specified by the offset parameter
  341. * @version Egret 2.4
  342. * @platform Web,Native
  343. * @language en_US
  344. */
  345. /**
  346. * 从指定的字节数组写入一系列字节。写入操作从 offset 指定的位置开始。
  347. * 如果省略了 length 参数,则默认长度 0 将导致该方法从 offset 开始写入整个缓冲区。
  348. * 如果还省略了 offset 参数,则写入整个缓冲区。
  349. * @param bytes 要从中读取数据的 ByteArray 对象
  350. * @param offset ByteArray 对象中从零开始的偏移量,应由此开始执行数据写入
  351. * @param length 要写入的字节数。默认值 0 导致从 offset 参数指定的值开始写入整个缓冲区
  352. * @version Egret 2.4
  353. * @platform Web,Native
  354. * @language zh_CN
  355. */
  356. WebSocket.prototype.writeBytes = function (bytes, offset, length) {
  357. if (offset === void 0) { offset = 0; }
  358. if (length === void 0) { length = 0; }
  359. if (!this._connected) {
  360. egret.$warn(3101);
  361. return;
  362. }
  363. if (!this._writeByte) {
  364. egret.$warn(3102);
  365. return;
  366. }
  367. this._bytesWrite = true;
  368. this._writeByte.writeBytes(bytes, offset, length);
  369. this.flush();
  370. };
  371. /**
  372. * Read data byte number specified by the length parameter from the socket. Read these bytes into the specified byte array starting from the location expressed by offset.
  373. * @param bytes The ByteArray object that data is read into
  374. * @param offset The offset for data reading starts from this byte array
  375. * @param length Byte number to be read Default value 0 indicates reading all available data
  376. * @version Egret 2.4
  377. * @platform Web,Native
  378. * @language en_US
  379. */
  380. /**
  381. * 从套接字读取 length 参数指定的数据字节数。从 offset 所表示的位置开始,将这些字节读入指定的字节数组
  382. * @param bytes 要将数据读入的 ByteArray 对象
  383. * @param offset 数据读取的偏移量应从该字节数组中开始
  384. * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据
  385. * @version Egret 2.4
  386. * @platform Web,Native
  387. * @language zh_CN
  388. */
  389. WebSocket.prototype.readBytes = function (bytes, offset, length) {
  390. if (offset === void 0) { offset = 0; }
  391. if (length === void 0) { length = 0; }
  392. if (!this._readByte) {
  393. egret.$warn(3102);
  394. return;
  395. }
  396. this._readByte.position = 0;
  397. this._readByte.readBytes(bytes, offset, length);
  398. this._readByte.clear();
  399. };
  400. Object.defineProperty(WebSocket.prototype, "connected", {
  401. /**
  402. * Indicates whether the Socket object is connected currently
  403. * @version Egret 2.4
  404. * @platform Web,Native
  405. * @language en_US
  406. */
  407. /**
  408. * 表示此 Socket 对象目前是否已连接
  409. * @version Egret 2.4
  410. * @platform Web,Native
  411. * @language zh_CN
  412. */
  413. get: function () {
  414. return this._connected;
  415. },
  416. enumerable: true,
  417. configurable: true
  418. });
  419. Object.defineProperty(WebSocket.prototype, "type", {
  420. /**
  421. * Format for sending and receiving data. The default setting is the character string format
  422. * @version Egret 2.4
  423. * @platform Web,Native
  424. * @language en_US
  425. */
  426. /**
  427. * 发送和接收数据的格式,默认是字符串格式
  428. * @version Egret 2.4
  429. * @platform Web,Native
  430. * @language zh_CN
  431. */
  432. get: function () {
  433. return this._type;
  434. },
  435. set: function (value) {
  436. this._type = value;
  437. if (value == WebSocket.TYPE_BINARY && !this._writeByte) {
  438. this._readByte = new egret.ByteArray();
  439. this._writeByte = new egret.ByteArray();
  440. }
  441. },
  442. enumerable: true,
  443. configurable: true
  444. });
  445. /**
  446. * Send and receive data in character string format
  447. * @version Egret 2.4
  448. * @platform Web,Native
  449. * @language en_US
  450. */
  451. /**
  452. * 以字符串格式发送和接收数据
  453. * @version Egret 2.4
  454. * @platform Web,Native
  455. * @language zh_CN
  456. */
  457. WebSocket.TYPE_STRING = "webSocketTypeString";
  458. /**
  459. * Send and receive data in binary format
  460. * @version Egret 2.4
  461. * @platform Web,Native
  462. * @language en_US
  463. */
  464. /**
  465. * 以二进制格式发送和接收数据
  466. * @version Egret 2.4
  467. * @platform Web,Native
  468. * @language zh_CN
  469. */
  470. WebSocket.TYPE_BINARY = "webSocketTypeBinary";
  471. return WebSocket;
  472. }(egret.EventDispatcher));
  473. egret.WebSocket = WebSocket;
  474. __reflect(WebSocket.prototype, "egret.WebSocket");
  475. })(egret || (egret = {}));
  476. //////////////////////////////////////////////////////////////////////////////////////
  477. //
  478. // Copyright (c) 2014-present, Egret Technology.
  479. // All rights reserved.
  480. // Redistribution and use in source and binary forms, with or without
  481. // modification, are permitted provided that the following conditions are met:
  482. //
  483. // * Redistributions of source code must retain the above copyright
  484. // notice, this list of conditions and the following disclaimer.
  485. // * Redistributions in binary form must reproduce the above copyright
  486. // notice, this list of conditions and the following disclaimer in the
  487. // documentation and/or other materials provided with the distribution.
  488. // * Neither the name of the Egret nor the
  489. // names of its contributors may be used to endorse or promote products
  490. // derived from this software without specific prior written permission.
  491. //
  492. // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  493. // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  494. // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  495. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  496. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  497. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA,
  498. // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  499. // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  500. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  501. // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  502. //
  503. //////////////////////////////////////////////////////////////////////////////////////
  504. var egret;
  505. (function (egret) {
  506. var web;
  507. (function (web) {
  508. /**
  509. * @private
  510. */
  511. var HTML5WebSocket = (function () {
  512. function HTML5WebSocket() {
  513. this.host = "";
  514. this.port = 0;
  515. if (!window["WebSocket"]) {
  516. egret.$error(3100);
  517. }
  518. }
  519. HTML5WebSocket.prototype.addCallBacks = function (onConnect, onClose, onSocketData, onError, thisObject) {
  520. this.onConnect = onConnect;
  521. this.onClose = onClose;
  522. this.onSocketData = onSocketData;
  523. this.onError = onError;
  524. this.thisObject = thisObject;
  525. };
  526. HTML5WebSocket.prototype.connect = function (host, port) {
  527. this.host = host;
  528. this.port = port;
  529. var socketServerUrl = "ws://" + this.host + ":" + this.port;
  530. this.socket = new window["WebSocket"](socketServerUrl);
  531. this.socket.binaryType = "arraybuffer";
  532. this._bindEvent();
  533. };
  534. HTML5WebSocket.prototype.connectByUrl = function (url) {
  535. this.socket = new window["WebSocket"](url);
  536. this.socket.binaryType = "arraybuffer";
  537. this._bindEvent();
  538. };
  539. HTML5WebSocket.prototype._bindEvent = function () {
  540. var that = this;
  541. var socket = this.socket;
  542. socket.onopen = function () {
  543. if (that.onConnect) {
  544. that.onConnect.call(that.thisObject);
  545. }
  546. };
  547. socket.onclose = function (e) {
  548. if (that.onClose) {
  549. that.onClose.call(that.thisObject);
  550. }
  551. };
  552. socket.onerror = function (e) {
  553. if (that.onError) {
  554. that.onError.call(that.thisObject);
  555. }
  556. };
  557. socket.onmessage = function (e) {
  558. if (that.onSocketData) {
  559. that.onSocketData.call(that.thisObject, e.data);
  560. }
  561. };
  562. };
  563. HTML5WebSocket.prototype.send = function (message) {
  564. this.socket.send(message);
  565. };
  566. HTML5WebSocket.prototype.close = function () {
  567. this.socket.close();
  568. };
  569. HTML5WebSocket.prototype.disconnect = function () {
  570. if (this.socket.disconnect) {
  571. this.socket.disconnect();
  572. }
  573. };
  574. return HTML5WebSocket;
  575. }());
  576. web.HTML5WebSocket = HTML5WebSocket;
  577. __reflect(HTML5WebSocket.prototype, "egret.web.HTML5WebSocket", ["egret.ISocket"]);
  578. egret.ISocket = HTML5WebSocket;
  579. })(web = egret.web || (egret.web = {}));
  580. })(egret || (egret = {}));