Skip to content

Commit 3672952

Browse files
committed
Close stream on subscription close
1 parent 1032954 commit 3672952

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/ipc/client.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,5 +815,20 @@ void ggipc_close_subscription(GgIpcSubscriptionHandle handle) {
815815
return;
816816
}
817817

818+
int32_t stream_id = stream_state_id[index];
819+
EventStreamHeader headers[] = {
820+
{ GGL_STR(":message-type"),
821+
{ EVENTSTREAM_INT32, .int32 = EVENTSTREAM_APPLICATION_MESSAGE } },
822+
{ GGL_STR(":message-flags"),
823+
{ EVENTSTREAM_INT32, .int32 = EVENTSTREAM_TERMINATE_STREAM } },
824+
{ GGL_STR(":stream-id"), { EVENTSTREAM_INT32, .int32 = stream_id } },
825+
};
826+
size_t headers_len = sizeof(headers) / sizeof(headers[0]);
827+
828+
GGL_LOGD(
829+
"Sending subscription termination for stream id %" PRIi32 ".", stream_id
830+
);
831+
(void) ipc_send_packet(ipc_conn_fd, headers, headers_len, GGL_NULL_READER);
832+
818833
clear_stream_index(index);
819834
}

0 commit comments

Comments
 (0)