SSEStream

Manages a Server-Sent Events (SSE) stream from a Horizon API endpoint. Provides automatic reconnection, cursor management, and event delivery.

This class handles:

  • Auto-reconnect with configurable timeout

  • Cursor tracking to resume from the last received event

  • Event filtering (ignoring "hello" and "byebye" messages)

  • Thread-safe lifecycle management

  • Proper resource cleanup

Parameters

T

The type of response objects expected from the stream

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns the paging token (cursor) of the last received event. This can be used to resume streaming from a specific point.

Link copied to clipboard

Duration to wait before attempting reconnection (default: 15 seconds)

Functions

Link copied to clipboard
fun close()

Closes the SSE stream and releases all resources. After calling this method, the stream cannot be restarted.