From a06a960947c784683179d3ee413dea47dc8c6b54 Mon Sep 17 00:00:00 2001 From: utf-4096 Date: Sat, 15 Jul 2023 16:49:13 +0200 Subject: [PATCH] feat: add sendKeepAlive --- src/Client.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Client.js b/src/Client.js index e9911bc..8e738d2 100644 --- a/src/Client.js +++ b/src/Client.js @@ -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,