Fix relay stats tracking a bit

This commit is contained in:
Jon Staab
2024-09-02 16:39:08 -07:00
parent b910569fc0
commit cb1993fa71
3 changed files with 26 additions and 21 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ export class Connection extends Emitter {
onClose = () => this.emit('close', this)
onError = () => this.emit('fault', this)
onFault = () => this.emit('fault', this)
onMessage = (m: SocketMessage) => this.receiver.push(m)
+3 -3
View File
@@ -14,7 +14,7 @@ export const asMessage = (m: SocketMessage): Message => isMessage(m) ? m : m[1]
export type SocketOpts = {
onOpen: () => void
onClose: () => void
onError: () => void
onFault: () => void
onMessage: (message: SocketMessage) => void
}
@@ -59,12 +59,12 @@ export class Socket {
try {
this.ws = new WebSocket(this.url)
this.ws.onopen = this.opts.onOpen
this.ws.onerror = this.opts.onError
this.ws.onerror = this.opts.onFault
this.ws.onclose = this.opts.onClose
this.ws.onmessage = this.onMessage
} catch (e) {
this.ws = 'invalid'
this.opts.onError()
this.opts.onFault()
}
while (this.isConnecting()) {