UNPKG

awv3

Version:
55 lines (46 loc) 1.27 kB
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; import jsonpatch from 'fast-json-patch'; import SocketIO from './socketio'; var _default = /*#__PURE__*/ function (_SocketIO) { _inheritsLoose(_default, _SocketIO); function _default(types) { var _this; if (types === void 0) { types = ['patch', 'message']; } _this = _SocketIO.call(this, { debug: true, credentials: [] }) || this; _this.messages = []; _this.state = { type: 'system', alive: true, errors: [], options: { publicport: 9000, privateport: 8080, binary: true, stdout: false, instances: 1 }, tasks: [], users: [], analyzers: [], sessions: [] }; _this.on('connected', function (socket) { _this.socket.on('debug', function (data) { SocketIO._ack(_this.socket); requestAnimationFrame(function (_) { if (data.type === 'patch' && types.includes('patch')) jsonpatch.apply(_this.state, data.patch);else if (data.type === 'message' && types.includes('message')) _this.messages.push(data); }); }); }); return _this; } return _default; }(SocketIO); export { _default as default };