WebSocketConnection
public protocol WebSocketConnection
Defines a WebSocket connection.
-
Connect to the WebSocket.
Declaration
Swift
func connect()
-
Send a UTF-8 formatted
String
over the WebSocket.Declaration
Swift
func send(string: String)
Parameters
string
The
String
that will be sent. -
Send some
Data
over the WebSocket.Declaration
Swift
func send(data: Data)
Parameters
data
The
Data
that will be sent. -
Start listening for messages over the WebSocket.
Declaration
Swift
func listen()
-
Ping the WebSocket periodically.
Declaration
Swift
func ping(interval: TimeInterval)
Parameters
interval
The
TimeInterval
(in seconds) with which to ping the server. -
Ping the WebSocket once.
Declaration
Swift
func ping()
-
Disconnect from the WebSocket.
Declaration
Swift
func disconnect(closeCode: NWProtocolWebSocket.CloseCode)
Parameters
closeCode
The code to use when closing the WebSocket connection.
-
The WebSocket connection delegate.
Declaration
Swift
var delegate: WebSocketConnectionDelegate? { get set }