feat: add sendKeepAlive

This commit is contained in:
2023-07-15 16:49:13 +02:00
parent 601314da36
commit a06a960947
+7 -3
View File
@@ -75,9 +75,7 @@ export class Client extends EventEmitter {
// send packets periodically to keep the connection alive
this.#keepAliveInterval = setInterval(async () => {
if ((Date.now() - this.#lastPacketDate) > 30000) {
await this.#protoRequest(KeepAlive.create({
data: Date.now()
}))
await this.sendKeepAlive()
}
}, 15000)
@@ -123,6 +121,12 @@ export class Client extends EventEmitter {
})
}
async sendKeepAlive() {
return await this.#protoRequest(KeepAlive.create({
data: Date.now()
}))
}
async #publish(port, flags) {
const response = await this.#protoRequest(PublishRequest.create({
port,