Class
WebSocket
public class WebSocket
Websocket representaton
Relationships
Conforms To
WebSocketConnection
Defines a websocket connection.
Initializers
init(url:autoReplyToPing:connectionQueue:additionalHeaders:)
public init(url: URL, autoReplyToPing: Bool = false, connectionQueue: DispatchQueue = .global(qos: .default), additionalHeaders: [String: String]? = [:])
Initialize a new websocket instance
Parameters
Name | Type | Description |
---|---|---|
url | URL |
Websocket url to connect to |
autoReplyToPing | Bool |
Flag to indicate whether the instance should auto reply to ping messages |
connectionQueue | DispatchQueue |
Queue on which the messages should be handled |
additionalHeaders | [String: String]? |
Additional HTTP header to include when connect to the server |
init(request:)
public convenience init(request: URLRequest)
Properties
delegate
var delegate: WebSocketConnectionDelegate?
Methods
connect()
public func connect()
send(string:)
public func send(string: String)
send(data:)
public func send(data: Data)
ping(interval:)
public func ping(interval: TimeInterval)
ping()
public func ping()
disconnect(closeCode:)
public func disconnect(closeCode: NWProtocolWebSocket.CloseCode = .protocolCode(.normalClosure))