diff --git a/client/src/neko/base.ts b/client/src/neko/base.ts index 9128af4..85ec947 100644 --- a/client/src/neko/base.ts +++ b/client/src/neko/base.ts @@ -62,8 +62,8 @@ export abstract class BaseClient extends EventEmitter { this._ws = new WebSocket(`${url}ws?password=${password}`) this.emit('debug', `connecting to ${this._ws.url}`) this._ws.onmessage = this.onMessage.bind(this) - this._ws.onerror = event => this.onError.bind(this) - this._ws.onclose = event => this.onDisconnected.bind(this, new Error('websocket closed')) + this._ws.onerror = (event) => this.onError.bind(this) + this._ws.onclose = (event) => this.onDisconnected.bind(this, new Error('websocket closed')) this._timeout = setTimeout(this.onTimeout.bind(this), 15000) } catch (err) { this.onDisconnected(err) @@ -179,15 +179,15 @@ export abstract class BaseClient extends EventEmitter { }) } - this._peer.onconnectionstatechange = event => { + this._peer.onconnectionstatechange = (event) => { this.emit('debug', `peer connection state changed`, this._peer ? this._peer.connectionState : undefined) } - this._peer.onsignalingstatechange = event => { + this._peer.onsignalingstatechange = (event) => { this.emit('debug', `peer signaling state changed`, this._peer ? this._peer.signalingState : undefined) } - this._peer.oniceconnectionstatechange = event => { + this._peer.oniceconnectionstatechange = (event) => { this._state = this._peer!.iceConnectionState this.emit('debug', `peer ice connection state changed: ${this._peer!.iceConnectionState}`) @@ -222,7 +222,7 @@ export abstract class BaseClient extends EventEmitter { this._peer.setRemoteDescription({ type: 'offer', sdp }) this._peer .createAnswer() - .then(d => { + .then((d) => { this._peer!.setLocalDescription(d) this._ws!.send( JSON.stringify({ @@ -232,7 +232,7 @@ export abstract class BaseClient extends EventEmitter { }), ) }) - .catch(err => this.emit('error', err)) + .catch((err) => this.emit('error', err)) } private onMessage(e: MessageEvent) { @@ -246,16 +246,14 @@ export abstract class BaseClient extends EventEmitter { this.createPeer(sdp, lite, ice) return } + if (event === EVENT.SIGNAL.CANDIDATE) { const { data } = payload as SignalCandidatePayload let candidate: RTCIceCandidate = JSON.parse(data) this._peer!.addIceCandidate(candidate) - return } - - // @ts-ignore if (typeof this[event] === 'function') { // @ts-ignore