Events
Description
When a client calls this endpoint, the server does not return immediately, but keeps the connection open until it is explicitly disconnected or a network error occurs. This method is called Server Sent Events (SSE), and is a way for the server to notify connected clients about server side events. The event is sent via the open connection. After a new client connects, the server immediately sends a clientRegistered event to the client. This event contains information about the client's supported report area(s) and whether there are any unread reports available.
Endpoint path
Call flow
sequenceDiagram Client->>Server: Call 'events' endpoint Server->>Client: Event 'clientRegistered' Client->>Server: If any unread reports, list and get those reports Note over Client: Process reports and wait for new events Server->>Client: Event 'newReport' Client->>Server: Get the new report Note over Client: Process report Client->>Server: Mark report as read
Required scopes
To be able call this endpoint, the HelseId client must have one of the following scopes:
nhn:melde/delivery/restricted-accessnhn:melde/delivery/full-access
Response
The events is sent from the server wrapped in a standard SSE 'envelope' via the events connection. The event payload looks like this:
{
"ReportArea": nn, // Report area id
"EventType": "", // One of clientRegistered, newReport, reportDeleted
"ReportRef": "", // Report reference or null if not relevant
"HasNewReports": true|false // true ,false or null if not relevant
}
See Swagger UI for more information