EventHandler

public protocol EventHandler

Protocol for an object that will receive SSE events.

  • EventSource calls this method when the stream connection has been opened.

    Declaration

    Swift

    func onOpened()
  • EventSource calls this method when the stream connection has been closed.

    Declaration

    Swift

    func onClosed()
  • EventSource calls this method when it has received a new event from the stream.

    Declaration

    Swift

    func onMessage(eventType: String, messageEvent: MessageEvent)

    Parameters

    eventType

    The type of the event.

    messageEvent

    The data for the event.

  • EventSource calls this method when it has received a comment line from the stream.

    Declaration

    Swift

    func onComment(comment: String)

    Parameters

    comment

    The comment received.

  • This method will be called for all exceptions that occur on the network connection (including an UnsuccessfulResponseError if the server returns an unexpected HTTP status), but only after the ConnectionErrorHandler (if any) has processed it. If you need to do anything that affects the state of the connection, use ConnectionErrorHandler.

    Declaration

    Swift

    func onError(error: Error)

    Parameters

    error

    The error received.