Archived
2
0
This commit is contained in:
Craig
2020-04-05 03:17:06 +00:00
parent fa64f930a9
commit 9d484a49d0
12 changed files with 31 additions and 31 deletions

View File

@ -62,8 +62,8 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
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)
@ -174,15 +174,15 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
this._peer = new RTCPeerConnection()
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}`)
@ -217,7 +217,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
this._peer.setRemoteDescription({ type: 'offer', sdp })
this._peer
.createAnswer()
.then(d => {
.then((d) => {
this._peer!.setLocalDescription(d)
this._ws!.send(
JSON.stringify({
@ -227,7 +227,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
}),
)
})
.catch(err => this.emit('error', err))
.catch((err) => this.emit('error', err))
}
private onMessage(e: MessageEvent) {