Config
public struct Config
Struct for configuring the EventSource.
-
The
EventHandlercalled in response to activity on the stream.Declaration
Swift
public let handler: EventHandler -
The
URLof 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
EventSourceconnection 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
URLSessionConfigurationused to create theURLSession.Important
Note that this copies the given
URLSessionConfigurationwhen set, and returns copies (updated with any overrides specified by other configuration options) when the value is retrieved. This prevents updating theURLSessionConfigurationafter initializingEventSourcewith theConfig, and prevents theEventSourcefrom updating any properties of the givenURLSessionConfiguration.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
EventHandlerand aURLDeclaration
Swift
public init(handler: EventHandler, url: URL)
View on GitHub
Config Structure Reference