UNPKG

awv3

Version:
31 lines (27 loc) 1.01 kB
import jsonpatch from 'fast-json-patch'; import SocketIO from './socketio'; export default class extends SocketIO { constructor(types = ['patch', 'message']) { super({ debug: true, credentials: [] }); 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', socket => { this.socket.on('debug', data => { SocketIO._ack(this.socket); requestAnimationFrame(_ => { 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); }); }); }); } }