You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
3.3 KiB

4 years ago
  1. 'use strict';
  2. /* eslint-disable
  3. no-unused-vars
  4. */
  5. function _typeof(obj) { 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); }
  6. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7. 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); } }
  8. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  10. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  11. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  12. 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); }
  13. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14. var SockJS = require('sockjs-client/dist/sockjs');
  15. var BaseClient = require('./BaseClient');
  16. module.exports =
  17. /*#__PURE__*/
  18. function (_BaseClient) {
  19. _inherits(SockJSClient, _BaseClient);
  20. function SockJSClient(url) {
  21. var _this;
  22. _classCallCheck(this, SockJSClient);
  23. _this = _possibleConstructorReturn(this, _getPrototypeOf(SockJSClient).call(this));
  24. _this.sock = new SockJS(url);
  25. _this.sock.onerror = function (err) {// TODO: use logger to log the error event once client and client-src
  26. // are reorganized to have the same directory structure
  27. };
  28. return _this;
  29. }
  30. _createClass(SockJSClient, [{
  31. key: "onOpen",
  32. value: function onOpen(f) {
  33. this.sock.onopen = f;
  34. }
  35. }, {
  36. key: "onClose",
  37. value: function onClose(f) {
  38. this.sock.onclose = f;
  39. } // call f with the message string as the first argument
  40. }, {
  41. key: "onMessage",
  42. value: function onMessage(f) {
  43. this.sock.onmessage = function (e) {
  44. f(e.data);
  45. };
  46. }
  47. }], [{
  48. key: "getClientPath",
  49. value: function getClientPath(options) {
  50. return require.resolve('./SockJSClient');
  51. }
  52. }]);
  53. return SockJSClient;
  54. }(BaseClient);