From 29856a9129495cf64b7b5f0d287485cf4e6963c1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 6 Jun 2023 09:16:38 +0900 Subject: [PATCH] tweak of 981e6f996 --- packages/frontend/src/stream.ts | 2 +- packages/misskey-js/src/streaming.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/stream.ts b/packages/frontend/src/stream.ts index a807d1d306..a7e4ecd42d 100644 --- a/packages/frontend/src/stream.ts +++ b/packages/frontend/src/stream.ts @@ -19,7 +19,7 @@ export function useStream(): Misskey.Stream { function heartbeat(): void { if (stream != null && document.visibilityState === 'visible') { - stream.send('ping'); + stream.heartbeat(); } window.setTimeout(heartbeat, 1000 * 60); } diff --git a/packages/misskey-js/src/streaming.ts b/packages/misskey-js/src/streaming.ts index 0218b40a03..92a220b496 100644 --- a/packages/misskey-js/src/streaming.ts +++ b/packages/misskey-js/src/streaming.ts @@ -186,6 +186,14 @@ export default class Stream extends EventEmitter { this.stream.send(JSON.stringify(typeOrPayload)); } + public ping(): void { + this.stream.send('ping'); + } + + public heartbeat(): void { + this.stream.send('h'); + } + /** * Close this connection */