feat: add tx/rx counters
This commit is contained in:
@@ -20,6 +20,8 @@ export class Client extends EventEmitter {
|
|||||||
#address
|
#address
|
||||||
#keepAliveInterval
|
#keepAliveInterval
|
||||||
#lastPacketDate = 0
|
#lastPacketDate = 0
|
||||||
|
#tx = 0
|
||||||
|
#rx = 0
|
||||||
|
|
||||||
constructor(gateway) {
|
constructor(gateway) {
|
||||||
super()
|
super()
|
||||||
@@ -37,6 +39,7 @@ export class Client extends EventEmitter {
|
|||||||
console.log('sending:', buf)
|
console.log('sending:', buf)
|
||||||
this.#ws.send(buf)
|
this.#ws.send(buf)
|
||||||
|
|
||||||
|
this.#tx++
|
||||||
this.#lastPacketDate = Date.now()
|
this.#lastPacketDate = Date.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +91,7 @@ export class Client extends EventEmitter {
|
|||||||
oneofs: true
|
oneofs: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.#rx++
|
||||||
this.emit('raw', container)
|
this.emit('raw', container)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,4 +195,12 @@ export class Client extends EventEmitter {
|
|||||||
get lastPacketDate() {
|
get lastPacketDate() {
|
||||||
return this.#lastPacketDate
|
return this.#lastPacketDate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get tx() {
|
||||||
|
return this.#tx
|
||||||
|
}
|
||||||
|
|
||||||
|
get rx() {
|
||||||
|
return this.#rx
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user