Skip to content

Add Server-Sent Events Sample - #67

Merged
adeutscher merged 31 commits into
developfrom
issue/66/server-sent-events
Sep 6, 2026
Merged

adeutscher merged 31 commits into
developfrom
issue/66/server-sent-events

Conversation

@adeutscher

Copy link
Copy Markdown
Owner

Server-Side Events can be used to send updates to a connected client in real time on one connection. This implementation uses the MQTT protocol to share events in such a way that multiple API instances could share events (local testing uses MiniStack to support MQTT over WebSockets).

Changes:

  • Add /messages endpoint to submit messages and /messages/event-stream endpoint to listen for messages.
    • Users can only receive messages that they themselves have sent, as the MQTT topic that events are published under is derived from the user's ID.
  • OpenAPI/Swagger does not understand handling event streams, so explicitly declared a class that could. This event stream listener attempts to behave like a Swagger class as much as possible, such as throwing SwaggerExceptions on HTTP errors.
  • Documented pattern in docs/patterns/server-sent-events.md, including generated code samples in several languages.

Tests Run:

  • Successfully sending messages.
  • Users successfully receive their own messages.
  • Users do not receive messages meant for other users.

@adeutscher adeutscher self-assigned this Sep 5, 2026
@adeutscher adeutscher added the enhancement New feature or request label Sep 5, 2026
@adeutscher adeutscher linked an issue Sep 5, 2026 that may be closed by this pull request
@adeutscher

Copy link
Copy Markdown
Owner Author

Everything still works, and testing was run. Can't think of a reason not to merge this.

@adeutscher
adeutscher merged commit 0ce0872 into develop Sep 6, 2026
1 check passed
@adeutscher
adeutscher deleted the issue/66/server-sent-events branch September 6, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example: Server-Sent Events

1 participant