Skip to content

Commit d0c7410

Browse files
polaon0xeb
authored andcommitted
Handle notifications in SSE server.
1 parent 734b799 commit d0c7410

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/server/sse_server.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,25 @@ bool SseServerWrapper::start()
511511
return;
512512
}
513513

514+
// Check if this is a notification (no "id" field means notification)
515+
// JSON-RPC 2.0 spec: server MUST NOT reply to notifications
516+
bool is_notification = !message.contains("id") || message["id"].is_null();
517+
518+
if (is_notification)
519+
{
520+
// For notifications, call handler but don't send response body
521+
try
522+
{
523+
handler_(message); // Process but ignore result
524+
}
525+
catch (...)
526+
{
527+
// Silently ignore errors for notifications
528+
}
529+
res.status = 202; // Accepted, no content
530+
return;
531+
}
532+
514533
// Normal request - process with handler
515534
auto response = handler_(message);
516535

0 commit comments

Comments
 (0)