WebSocketEvents

public struct WebSocketEvents

The WebSocketEvents struct is used by the events property and manages the events for the WebSocket connection.

  • An event to be called when the WebSocket connection’s readyState changes to .Open; this indicates that the connection is ready to send and receive data.

    Declaration

    Swift

    public var open: () -> ()
  • An event to be called when the WebSocket connection’s readyState changes to .Closed.

    Declaration

    Swift

    public var close: (_ code: Int, _ reason: String, _ wasClean: Bool) -> ()
  • An event to be called when an error occurs.

    Declaration

    Swift

    public var error: (_ error: Error) -> ()
  • An event to be called when a message is received from the server.

    Declaration

    Swift

    public var message: (_ data: Any) -> ()
  • An event to be called when a pong is received from the server.

    Declaration

    Swift

    public var pong: (_ data: Any) -> ()
  • end

    An event to be called when the WebSocket process has ended; this event is guarenteed to be called once and can be used as an alternative to the “close” or “error” events.

    Declaration

    Swift

    public var end: (_ code: Int, _ reason: String, _ wasClean: Bool, _ error: Error?) -> ()