feat: add sendKeepAlive
This commit is contained in:
+7
-3
@@ -75,9 +75,7 @@ export class Client extends EventEmitter {
|
|||||||
// send packets periodically to keep the connection alive
|
// send packets periodically to keep the connection alive
|
||||||
this.#keepAliveInterval = setInterval(async () => {
|
this.#keepAliveInterval = setInterval(async () => {
|
||||||
if ((Date.now() - this.#lastPacketDate) > 30000) {
|
if ((Date.now() - this.#lastPacketDate) > 30000) {
|
||||||
await this.#protoRequest(KeepAlive.create({
|
await this.sendKeepAlive()
|
||||||
data: Date.now()
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
}, 15000)
|
}, 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) {
|
async #publish(port, flags) {
|
||||||
const response = await this.#protoRequest(PublishRequest.create({
|
const response = await this.#protoRequest(PublishRequest.create({
|
||||||
port,
|
port,
|
||||||
|
|||||||
Reference in New Issue
Block a user