WebSocketDelegate

@objc
public protocol WebSocketDelegate

WebSocketDelegate is an Objective-C alternative to WebSocketEvents and is used to delegate the events for the WebSocket connection.

  • A function 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

    func webSocketOpen()
  • A function to be called when the WebSocket connection’s readyState changes to .Closed.

    Declaration

    Swift

    func webSocketClose(_ code: Int, reason: String, wasClean: Bool)
  • A function to be called when an error occurs.

    Declaration

    Swift

    func webSocketError(_ error: NSError)
  • A function to be called when a message (string) is received from the server.

    Declaration

    Swift

    @objc
    optional func webSocketMessageText(_ text: String)
  • A function to be called when a message (binary) is received from the server.

    Declaration

    Swift

    @objc
    optional func webSocketMessageData(_ data: Data)
  • A function to be called when a pong is received from the server.

    Declaration

    Swift

    @objc
    optional func webSocketPong()
  • A function 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

    @objc
    optional func webSocketEnd(_ code: Int, reason: String, wasClean: Bool, error: NSError?)