From 3fe319a781281a9e6efe564e1134649b7af19961 Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Fri, 26 Apr 2024 11:47:19 +0200 Subject: [PATCH] Added custom-layout for v2 compatibility to PRO deloyment --- pro/custom-layout/index.html | 76 +++++++++++++++++-- pro/custom-layout/opentok-layout.min.js | 12 +++ .../openvidu-browser-3.0.0-dev2.min.js | 2 + ...vidu-browser-3.0.0-dev2.min.js.LICENSE.txt | 13 ++++ 4 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 pro/custom-layout/opentok-layout.min.js create mode 100644 pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js create mode 100644 pro/custom-layout/openvidu-browser-3.0.0-dev2.min.js.LICENSE.txt diff --git a/pro/custom-layout/index.html b/pro/custom-layout/index.html index fbb8350..b401532 100644 --- a/pro/custom-layout/index.html +++ b/pro/custom-layout/index.html @@ -1,11 +1,71 @@ -
- - -n&&t[i]<0&&(n=t[i]);return n}(c,a);n.emit("volume_change",e,u);var t=0;if(e>u&&!n.speaking){for(var i=n.speakingHistory.length-3;ie instanceof c?e:new c(e)));else if(void 0!==o[n]){const e=o[n];c.fieldWrapper?"google.protobuf.BytesValue"===c.typeName?r[n]=he(e):r[n]=e:r[n]=e instanceof c?e:new c(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every((e=>{const i=t[e.localName],r=n[e.localName];if(e.repeated){if(i.length!==r.length)return!1;switch(e.kind){case"message":return i.every(((t,n)=>e.T.equals(t,r[n])));case"scalar":return i.every(((t,n)=>A(e.T,t,r[n])));case"enum":return i.every(((e,t)=>A(g.INT32,e,r[t])))}throw new Error("repeated cannot contain ".concat(e.kind))}switch(e.kind){case"message":return e.T.equals(i,r);case"enum":return A(g.INT32,i,r);case"scalar":return A(e.T,i,r);case"oneof":if(i.case!==r.case)return!1;const t=e.findField(i.case);if(void 0===t)return!0;switch(t.kind){case"message":return t.T.equals(i.value,r.value);case"enum":return A(g.INT32,i.value,r.value);case"scalar":return A(t.T,i.value,r.value)}throw new Error("oneof cannot contain ".concat(t.kind));case"map":const n=Object.keys(i).concat(Object.keys(r));switch(e.V.kind){case"message":const t=e.V.T;return n.every((e=>t.equals(i[e],r[e])));case"enum":return n.every((e=>A(g.INT32,i[e],r[e])));case"scalar":const o=e.V.T;return n.every((e=>A(o,i[e],r[e])))}}})),clone(e){const t=e.getType(),n=new t,i=n;for(const n of t.fields.byMember()){const t=e[n.localName];let r;if(n.repeated)r=t.map(ue);else if("map"==n.kind){r=i[n.localName];for(const[e,n]of Object.entries(t))r[e]=ue(n)}else r="oneof"==n.kind?n.findField(t.case)?{case:t.case,value:ue(t.value)}:{case:void 0}:ue(t);i[n.localName]=r}return n}}),{newFieldList:e=>new pe(e,_e),initFields(e){for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,i=e;if(t.repeated)i[n]=[];else switch(t.kind){case"oneof":i[n]={case:void 0};break;case"enum":i[n]=0;break;case"map":i[n]={};break;case"scalar":i[n]=M(t.T,t.L)}}}}),{syntax:"proto3",json:Ce,bin:we,util:Pe,makeMessageType(e,t,n){return function(e,t,n,i){var r;const o=null!==(r=null==i?void 0:i.localName)&&void 0!==r?r:t.substring(t.lastIndexOf(".")+1),s={[o]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[o];return Object.setPrototypeOf(s.prototype,new f),Object.assign(s,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary:(e,t)=>(new s).fromBinary(e,t),fromJson:(e,t)=>(new s).fromJson(e,t),fromJsonString:(e,t)=>(new s).fromJsonString(e,t),equals:(t,n)=>e.util.equals(s,t,n)}),s}(this,e,t,n)},makeEnum:function(e,t,n){const i={};for(const e of t){const t=m(e);i[t.localName]=t.no,i[t.no]=t.localName}return h(i,e,t),i},makeEnumType:p,getEnumType:function(e){const n=e[u];return t(n,"missing enum type on enum object"),n},makeExtension(e,t,n){return function(e,t,n,i){let r;return{typeName:t,extendee:n,get field(){if(!r){const n="function"==typeof i?i():i;n.name=t.split(".").pop(),n.jsonName="[".concat(t,"]"),r=e.util.newFieldList([n]).list()[0]}return r},runtime:e}}(this,e,t,n)}});var Ce,we,Pe;function _e(e){var t,n,i,r;const o=[];let s;for(const a of"function"==typeof e?e():e){const e=a;if(e.localName=me(a.name,void 0!==a.oneof),e.jsonName=null!==(t=a.jsonName)&&void 0!==t?t:fe(a.name),e.repeated=null!==(n=a.repeated)&&void 0!==n&&n,"scalar"==a.kind&&(e.L=null!==(i=a.L)&&void 0!==i?i:v.BIGINT),void 0!==a.oneof){const t="string"==typeof a.oneof?a.oneof:a.oneof.name;s&&s.name==t||(s=new Ee(t)),e.oneof=s,s.addField(e)}"message"==a.kind&&(e.delimited=!1),e.packed=null!==(r=a.packed)&&void 0!==r?r:"enum"==a.kind||"scalar"==a.kind&&a.T!=g.BYTES&&a.T!=g.STRING,o.push(e)}return o}class Re extends f{constructor(e){super(),this.seconds=R.zero,this.nanos=0,Se.util.initPartial(e,this)}fromJson(e,t){if("string"!=typeof e)throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(Se.json.debug(e)));const n=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const i=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(i))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(ibi(this,void 0,void 0,(function*(){if(!this.pcManager)return void n(new po("PC manager is closed"));this.pcManager.requirePublisher();const i=new AbortController,r=()=>{i.abort(),this.log.debug("engine disconnected while negotiation was ongoing",this.logContext),t()};this.isClosed&&n("cannot negotiate on closed engine"),this.on(e.EngineEvent.Closing,r),this.pcManager.publisher.once(Js,(t=>{const n=new Map;t.forEach((e=>{const t=e.codec.toLowerCase();var i;i=t,Co.includes(i)&&n.set(e.payload,t)})),this.emit(e.EngineEvent.RTPVideoMapUpdate,n)}));try{yield this.pcManager.negotiate(i),t()}catch(e){e instanceof po&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",Fe.RR_UNKNOWN),n(e)}finally{this.off(e.EngineEvent.Closing,r)}}))))}))}dataChannelForKind(e,t){if(t){if(e===Qe.LOSSY)return this.lossyDCSub;if(e===Qe.RELIABLE)return this.reliableDCSub}else{if(e===Qe.LOSSY)return this.lossyDC;if(e===Qe.RELIABLE)return this.reliableDC}}sendSyncState(e,t){var n,i;if(!this.pcManager)return void this.log.warn("sync state cannot be sent without peer connection setup",this.logContext);const r=this.pcManager.subscriber.getLocalDescription(),o=this.pcManager.subscriber.getRemoteDescription(),s=null===(i=null===(n=this.signalOpts)||void 0===n?void 0:n.autoSubscribe)||void 0===i||i,a=new Array,c=new Array;e.forEach((e=>{e.isDesired!==s&&a.push(e.trackSid),e.isEnabled||c.push(e.trackSid)})),this.client.sendSyncState(new Ln({answer:r?Ms({sdp:r.sdp,type:r.type}):void 0,offer:o?Ms({sdp:o.sdp,type:o.type}):void 0,subscription:new vn({trackSids:a,subscribe:!s,participantTracks:[]}),publishTracks:Vo(t),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:c}))}failNext(){this.shouldFailNext=!0}dataChannelsInfo(){const e=[],t=(t,n)=>{void 0!==(null==t?void 0:t.id)&&null!==t.id&&e.push(new Un({label:t.label,id:t.id,target:n}))};return t(this.dataChannelForKind(Qe.LOSSY),tn.PUBLISHER),t(this.dataChannelForKind(Qe.RELIABLE),tn.PUBLISHER),t(this.dataChannelForKind(Qe.LOSSY,!0),tn.SUBSCRIBER),t(this.dataChannelForKind(Qe.RELIABLE,!0),tn.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&To.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){ns()&&window.addEventListener("online",this.handleBrowserOnLine)}deregisterOnLineListener(){ns()&&window.removeEventListener("online",this.handleBrowserOnLine)}}class la extends Error{}class ua{constructor(e,t){this.lastUpdateAt=0,this.settingsCacheTime=3e3,this.attemptedRegions=[],this.serverUrl=new URL(e),this.token=t}updateToken(e){this.token=e}isCloud(){return rs(this.serverUrl)}getServerUrl(){return this.serverUrl}getNextBestRegionUrl(e){return bi(this,void 0,void 0,(function*(){if(!this.isCloud())throw Error("region availability is only supported for LiveKit Cloud domains");(!this.regionSettings||Date.now()-this.lastUpdateAt>this.settingsCacheTime)&&(this.regionSettings=yield this.fetchRegionSettings(e));const t=this.regionSettings.regions.filter((e=>!this.attemptedRegions.find((t=>t.url===e.url))));if(t.length>0){const e=t[0];return this.attemptedRegions.push(e),hi.debug("next region: ".concat(e.region)),e.url}return null}))}resetAttempts(){this.attemptedRegions=[]}fetchRegionSettings(e){return bi(this,void 0,void 0,(function*(){const t=yield fetch("".concat((n=this.serverUrl,"".concat(n.protocol.replace("ws","http"),"//").concat(n.host,"/settings")),"/regions"),{headers:{authorization:"Bearer ".concat(this.token)},signal:e});var n;if(t.ok){const e=yield t.json();return this.lastUpdateAt=Date.now(),e}throw new ao("Could not fetch region settings: ".concat(t.statusText),401===t.status?0:void 0,t.status)}))}}const ha=2e3;function pa(e,t){if(!t)return 0;let n,i;return"bytesReceived"in e?(n=e.bytesReceived,i=t.bytesReceived):"bytesSent"in e&&(n=e.bytesSent,i=t.bytesSent),void 0===n||void 0===i||void 0===e.timestamp||void 0===t.timestamp?0:8*(n-i)*1e3/(e.timestamp-t.timestamp)}class ma extends ws{constructor(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;super(e,Io.Kind.Audio,t,n,r),this.stopOnMute=!1,this.monitorSender=()=>bi(this,void 0,void 0,(function*(){if(!this.sender)return void(this._currentBitrate=0);let e;try{e=yield this.getSenderStats()}catch(e){return void this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:e}))}e&&this.prevStats&&(this._currentBitrate=pa(e,this.prevStats)),this.prevStats=e})),this.audioContext=i,this.checkForSilence()}setDeviceId(e){return bi(this,void 0,void 0,(function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===Ts(e)||(this._constraints.deviceId=e,this.isMuted||(yield this.restartTrack()),this.isMuted||Ts(e)===this._mediaStreamTrack.getSettings().deviceId)}))}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return bi(this,void 0,void 0,(function*(){const t=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===Io.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(this.log.debug("stopping mic track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{t()}}))}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return bi(this,void 0,void 0,(function*(){const t=yield this.muteLock.lock();try{if(!this.isMuted)return this.log.debug("Track already unmuted",this.logContext),this;const t=this._constraints.deviceId&&this._mediaStreamTrack.getSettings().deviceId!==Ts(this._constraints.deviceId);return this.source!==Io.Source.Microphone||!this.stopOnMute&&"ended"!==this._mediaStreamTrack.readyState&&!t||this.isUserProvided||(this.log.debug("reacquiring mic track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this}finally{t()}}))}restartTrack(e){return bi(this,void 0,void 0,(function*(){let t;if(e){const n=Lo({audio:e});"boolean"!=typeof n.audio&&(t=n.audio)}yield this.restart(t)}))}restart(e){const t=Object.create(null,{restart:{get:()=>super.restart}});return bi(this,void 0,void 0,(function*(){const n=yield t.restart.call(this,e);return this.checkForSilence(),n}))}startMonitor(){ns()&&(this.monitorInterval||(this.monitorInterval=setInterval((()=>{this.monitorSender()}),ha)))}setProcessor(t){var n;return bi(this,void 0,void 0,(function*(){const i=yield this.processorLock.lock();try{if(!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.stopProcessor());const i={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext};this.log.debug("setting up audio processor ".concat(t.name),this.logContext),yield t.init(i),this.processor=t,this.processor.processedTrack&&(yield null===(n=this.sender)||void 0===n?void 0:n.replaceTrack(this.processor.processedTrack)),this.emit(e.TrackEvent.TrackProcessorUpdate,this.processor)}finally{i()}}))}setAudioContext(e){this.audioContext=e}getSenderStats(){var e;return bi(this,void 0,void 0,(function*(){if(!(null===(e=this.sender)||void 0===e?void 0:e.getStats))return;let t;return(yield this.sender.getStats()).forEach((e=>{"outbound-rtp"===e.type&&(t={type:"audio",streamId:e.id,packetsSent:e.packetsSent,packetsLost:e.packetsLost,bytesSent:e.bytesSent,timestamp:e.timestamp,roundTripTime:e.roundTripTime,jitter:e.jitter})})),t}))}checkForSilence(){return bi(this,void 0,void 0,(function*(){const t=yield function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:200;return bi(this,void 0,void 0,(function*(){const n=Uo();if(n){const i=n.createAnalyser();i.fftSize=2048;const r=i.frequencyBinCount,o=new Uint8Array(r);n.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(i),yield qo(t),i.getByteTimeDomainData(o);const s=o.some((e=>128!==e&&0!==e));return n.close(),!s}return!1}))}(this);return t&&(this.isMuted||this.log.warn("silence detected on local audio track",this.logContext),this.emit(e.TrackEvent.AudioSilenceDetected)),t}))}}function fa(e,t,n){switch(e.kind){case"audio":return new ma(e,t,!1,void 0,n);case"video":return new Ra(e,t,!1,n);default:throw new lo("unsupported track type: ".concat(e.kind))}}const ga=Object.values(_o),va=Object.values(Ro),ya=Object.values(Oo),ba=[_o.h180,_o.h360],ka=[Ro.h180,Ro.h360],Ta=e=>[{scaleResolutionDownBy:2,fps:e.encoding.maxFramerate}].map((t=>{var n,i;return new Eo(Math.floor(e.width/t.scaleResolutionDownBy),Math.floor(e.height/t.scaleResolutionDownBy),Math.max(15e4,Math.floor(e.encoding.maxBitrate/(Math.pow(t.scaleResolutionDownBy,2)*((null!==(n=e.encoding.maxFramerate)&&void 0!==n?n:30)/(null!==(i=t.fps)&&void 0!==i?i:30))))),t.fps,e.encoding.priority)})),Ea=["q","h","f"];function Sa(e,t,n,i){var r,o;let s=null==i?void 0:i.videoEncoding;e&&(s=null==i?void 0:i.screenShareEncoding);const a=null==i?void 0:i.simulcast,c=null==i?void 0:i.scalabilityMode,d=null==i?void 0:i.videoCodec;if(!s&&!a&&!c||!t||!n)return[{}];s||(s=function(e,t,n,i){const r=function(e,t,n){if(e)return ya;const i=t>n?t/n:n/t;return Math.abs(i-16/9)e){h.enqueue(o.ERROR_PACKET);break}}}})},t.protocol=4},7743:(e,t)=>{"use strict";function n(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Object.defineProperty(t,"__esModule",{value:!0}),t.Backoff=void 0,t.Backoff=n,n.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}},8007:function(e,t,n){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.connect=t.io=t.Socket=t.Manager=t.protocol=void 0;const r=n(6894),o=n(3776);Object.defineProperty(t,"Manager",{enumerable:!0,get:function(){return o.Manager}});const s=n(6214);Object.defineProperty(t,"Socket",{enumerable:!0,get:function(){return s.Socket}});const a=i(n(9368)).default("socket.io-client"),c={};function d(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};const n=r.url(e,t.path||"/socket.io"),i=n.source,s=n.id,d=n.path,l=c[s]&&d in c[s].nsps;let u;return t.forceNew||t["force new connection"]||!1===t.multiplex||l?(a("ignoring socket cache for %s",i),u=new o.Manager(i,t)):(c[s]||(a("new io instance for %s",i),c[s]=new o.Manager(i,t)),u=c[s]),n.query&&!t.query&&(t.query=n.queryKey),u.socket(n.path,t)}t.io=d,t.connect=d,t.default=d,Object.assign(d,{Manager:o.Manager,Socket:s.Socket,io:d,connect:d});var l=n(4627);Object.defineProperty(t,"protocol",{enumerable:!0,get:function(){return l.protocol}}),e.exports=d},3776:function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&i(t,e,n);return r(t,e),t},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Manager=void 0;const a=n(4956),c=n(6214),d=o(n(4627)),l=n(5942),u=n(7743),h=n(7285),p=s(n(9368)).default("socket.io-client:manager");class m extends h.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,a.installTimerFunctions(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new u.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||d;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(p("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;p("opening %s",this.uri),this.engine=new a.Socket(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=l.on(t,"open",(function(){n.onopen(),e&&e()})),r=t=>{p("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},o=l.on(t,"error",r);if(!1!==this._timeout){const e=this._timeout;p("connect attempt will timeout after %d",e);const n=this.setTimeoutFn((()=>{p("connect attempt timed out after %d",e),i(),r(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}return this.subs.push(i),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){p("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(l.on(e,"ping",this.onping.bind(this)),l.on(e,"data",this.ondata.bind(this)),l.on(e,"error",this.onerror.bind(this)),l.on(e,"close",this.onclose.bind(this)),l.on(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){a.nextTick((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){p("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new c.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t)if(this.nsps[e].active)return void p("socket %s is still active, skipping close",e);this._close()}_packet(e){p("writing packet %j",e);const t=this.encoder.encode(e);for(let n=0;n