1 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
2 |
|
3 | function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
4 |
|
5 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
6 |
|
7 | import SockJS from "../modules/sockjs-client/index.js";
|
8 | import { log } from "../utils/log.js";
|
9 |
|
10 | var SockJSClient = function () {
|
11 | |
12 |
|
13 |
|
14 | function SockJSClient(url) {
|
15 | _classCallCheck(this, SockJSClient);
|
16 |
|
17 |
|
18 | this.sock = new SockJS(url.replace(/^ws:/i, "http:").replace(/^wss:/i, "https:"));
|
19 |
|
20 | this.sock.onerror =
|
21 | |
22 |
|
23 |
|
24 | function (error) {
|
25 | log.error(error);
|
26 | };
|
27 | }
|
28 | |
29 |
|
30 |
|
31 |
|
32 |
|
33 | _createClass(SockJSClient, [{
|
34 | key: "onOpen",
|
35 | value: function onOpen(f) {
|
36 | this.sock.onopen = f;
|
37 | }
|
38 | |
39 |
|
40 |
|
41 |
|
42 | }, {
|
43 | key: "onClose",
|
44 | value: function onClose(f) {
|
45 | this.sock.onclose = f;
|
46 | }
|
47 |
|
48 | |
49 |
|
50 |
|
51 |
|
52 | }, {
|
53 | key: "onMessage",
|
54 | value: function onMessage(f) {
|
55 | this.sock.onmessage =
|
56 | |
57 |
|
58 |
|
59 | function (e) {
|
60 | f(e.data);
|
61 | };
|
62 | }
|
63 | }]);
|
64 |
|
65 | return SockJSClient;
|
66 | }();
|
67 |
|
68 | export { SockJSClient as default }; |
\ | No newline at end of file |