Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
enhancement: keep-alive
Browse files Browse the repository at this point in the history
  • Loading branch information
clement2026 committed Oct 4, 2023
1 parent d0f181c commit 540e095
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/api/sse/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const EventMessageAudio = "message/audio"
export const EventMessageError = "message/error"
export const EventSystemAbility = "system/ability"
export const EventSystemNotification = "system/notification"
export const EventKeepAlive = ""

export type SSEMsgMeta = {
// unique ID for the whole chat(contains maybe hundreds of messages)
Expand Down
6 changes: 5 additions & 1 deletion src/api/sse/sse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
EventMessageTextEOF,
EventMessageTextTyping,
EventMessageThinking,
EventSystemAbility,
EventSystemAbility, EventKeepAlive,
SSEMsgAudio,
SSEMsgError,
SSEMsgMeta,
Expand Down Expand Up @@ -116,6 +116,10 @@ export const SSE = () => {
}
})

eventSource.addEventListener(EventKeepAlive, () => {
// nothing to do
})

return () => {
console.info("[SSE] trying to abort")
eventSource.close()
Expand Down

0 comments on commit 540e095

Please sign in to comment.