source: trip-planner-front/node_modules/webpack-dev-server/client/clients/WebsocketClient.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.1 KB
Line 
1'use strict';
2/* global WebSocket */
3
4/* eslint-disable
5 no-unused-vars
6*/
7
8function _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); }
9
10function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
11
12function _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); } }
13
14function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
15
16function _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); }
17
18function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
19
20function _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); }; }
21
22function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
23
24function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
25
26function _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; } }
27
28function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
29
30var BaseClient = require('./BaseClient');
31
32module.exports = /*#__PURE__*/function (_BaseClient) {
33 _inherits(WebsocketClient, _BaseClient);
34
35 var _super = _createSuper(WebsocketClient);
36
37 function WebsocketClient(url) {
38 var _this;
39
40 _classCallCheck(this, WebsocketClient);
41
42 _this = _super.call(this);
43 _this.client = new WebSocket(url.replace(/^http/, 'ws'));
44
45 _this.client.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(WebsocketClient, [{
53 key: "onOpen",
54 value: function onOpen(f) {
55 this.client.onopen = f;
56 }
57 }, {
58 key: "onClose",
59 value: function onClose(f) {
60 this.client.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.client.onmessage = function (e) {
67 f(e.data);
68 };
69 }
70 }], [{
71 key: "getClientPath",
72 value: function getClientPath(options) {
73 return require.resolve('./WebsocketClient');
74 }
75 }]);
76
77 return WebsocketClient;
78}(BaseClient);
Note: See TracBrowser for help on using the repository browser.