Config

public struct Config

Struct for configuring the EventSource.

  • The EventHandler called in response to activity on the stream.

    Declaration

    Swift

    public let handler: EventHandler
  • url

    The URL of the request used when connecting to the EventSource API.

    Declaration

    Swift

    public let url: URL
  • The HTTP method to use for the API request.

    Declaration

    Swift

    public var method: String
  • Optional HTTP body to be included in the API request.

    Declaration

    Swift

    public var body: Data?
  • An initial value for the last-event-id header to be sent on the initial request

    Declaration

    Swift

    public var lastEventId: String
  • Additional HTTP headers to be set on the request

    Declaration

    Swift

    public var headers: [String : String]
  • Transform function to allow dynamically configuring the headers on each API request.

    Declaration

    Swift

    public var headerTransform: HeaderTransform
  • The minimum amount of time to wait before reconnecting after a failure

    Declaration

    Swift

    public var reconnectTime: TimeInterval
  • The maximum amount of time to wait before reconnecting after a failure

    Declaration

    Swift

    public var maxReconnectTime: TimeInterval
  • The minimum amount of time for an EventSource connection to remain open before allowing the connection backoff to reset.

    Declaration

    Swift

    public var backoffResetThreshold: TimeInterval
  • The maximum amount of time between receiving any data before considering the connection to have timed out.

    Declaration

    Swift

    public var idleTimeout: TimeInterval
  • The URLSessionConfiguration used to create the URLSession.

    Important

    Note that this copies the given URLSessionConfiguration when set, and returns copies (updated with any overrides specified by other configuration options) when the value is retrieved. This prevents updating the URLSessionConfiguration after initializing EventSource with the Config, and prevents the EventSource from updating any properties of the given URLSessionConfiguration.

    Since

    1.3.0

    Declaration

    Swift

    public var urlSessionConfiguration: URLSessionConfiguration { get set }
  • An error handler that is called when an error occurs and can shut down the client in response.

    The default error handler will always attempt to reconnect on an error, unless EventSource.stop() is called or the error code is 204.

    Declaration

    Swift

    public var connectionErrorHandler: ConnectionErrorHandler
  • Create a new configuration with an EventHandler and a URL

    Declaration

    Swift

    public init(handler: EventHandler, url: URL)