WebSocketClient
PROTOCOL
WebSocketClient
1public protocol WebSocketClient: AnyObject
Protocol allowing alternative implementations of websockets beyond ApolloWebSocket
.
Properties
request
1var request: URLRequest
The URLRequest used on connection.
delegate
1var delegate: WebSocketClientDelegate?
The delegate that will receive networking event updates for this websocket client.
Note: The
WebSocketTransport
will set itself as the delgate for the client. Consumers should set themselves as the delegate for theWebSocketTransport
to observe events.
callbackQueue
1var callbackQueue: DispatchQueue
DispatchQueue
where the websocket client should call all delegate callbacks.
Methods
connect()
1func connect()
Connects to the websocket server.
Note: This should be implemented to connect the websocket on a background thread.
disconnect()
1func disconnect()
Disconnects from the websocket server.
write(ping:completion:)
1func write(ping: Data, completion: (() -> Void)?)
Writes ping data to the websocket.
write(string:)
1func write(string: String)
Writes a string to the websocket.