EventSource

public class EventSource

Provides an EventSource client for consuming Server-Sent Events.

See the Server-Sent Events spec for more details.

  • Initialize the EventSource client with the given configuration.

    Declaration

    Swift

    public init(config: Config)

    Parameters

    config

    The configuration for initializing the EventSource client.

  • Start the EventSource client.

    This will initiate a streaming connection to the configured URL. The application will be informed of received events and state changes using the configured EventHandler.

    Declaration

    Swift

    public func start()
  • Shuts down the EventSource client. It is not valid to restart the client after calling this function.

    Declaration

    Swift

    public func stop()
  • Get the most recently received event ID, or the value of EventSource.Config.lastEventId if no event IDs have been received.

    Declaration

    Swift

    public func getLastEventId() -> String?
  • Struct for configuring the EventSource.

    See more

    Declaration

    Swift

    public struct Config