[6a3a178] | 1 | 'use strict';
|
---|
| 2 | /* eslint-disable
|
---|
| 3 | no-unused-vars
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
---|
| 7 |
|
---|
| 8 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
---|
| 9 |
|
---|
| 10 | 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); } }
|
---|
| 11 |
|
---|
| 12 | function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
---|
| 13 |
|
---|
| 14 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
---|
| 15 |
|
---|
| 16 | function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
---|
| 17 |
|
---|
| 18 | function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
---|
| 19 |
|
---|
| 20 | function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
---|
| 21 |
|
---|
| 22 | function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
---|
| 23 |
|
---|
| 24 | function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
---|
| 25 |
|
---|
| 26 | function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
---|
| 27 |
|
---|
| 28 | var SockJS = require('sockjs-client/dist/sockjs');
|
---|
| 29 |
|
---|
| 30 | var BaseClient = require('./BaseClient');
|
---|
| 31 |
|
---|
| 32 | module.exports = /*#__PURE__*/function (_BaseClient) {
|
---|
| 33 | _inherits(SockJSClient, _BaseClient);
|
---|
| 34 |
|
---|
| 35 | var _super = _createSuper(SockJSClient);
|
---|
| 36 |
|
---|
| 37 | function SockJSClient(url) {
|
---|
| 38 | var _this;
|
---|
| 39 |
|
---|
| 40 | _classCallCheck(this, SockJSClient);
|
---|
| 41 |
|
---|
| 42 | _this = _super.call(this);
|
---|
| 43 | _this.sock = new SockJS(url);
|
---|
| 44 |
|
---|
| 45 | _this.sock.onerror = function (err) {// TODO: use logger to log the error event once client and client-src
|
---|
| 46 | // are reorganized to have the same directory structure
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | return _this;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | _createClass(SockJSClient, [{
|
---|
| 53 | key: "onOpen",
|
---|
| 54 | value: function onOpen(f) {
|
---|
| 55 | this.sock.onopen = f;
|
---|
| 56 | }
|
---|
| 57 | }, {
|
---|
| 58 | key: "onClose",
|
---|
| 59 | value: function onClose(f) {
|
---|
| 60 | this.sock.onclose = f;
|
---|
| 61 | } // call f with the message string as the first argument
|
---|
| 62 |
|
---|
| 63 | }, {
|
---|
| 64 | key: "onMessage",
|
---|
| 65 | value: function onMessage(f) {
|
---|
| 66 | this.sock.onmessage = function (e) {
|
---|
| 67 | f(e.data);
|
---|
| 68 | };
|
---|
| 69 | }
|
---|
| 70 | }], [{
|
---|
| 71 | key: "getClientPath",
|
---|
| 72 | value: function getClientPath(options) {
|
---|
| 73 | return require.resolve('./SockJSClient');
|
---|
| 74 | }
|
---|
| 75 | }]);
|
---|
| 76 |
|
---|
| 77 | return SockJSClient;
|
---|
| 78 | }(BaseClient); |
---|