WebSocketKit Documentation Beta

Class Web​Socket

public class WebSocket

Websocket representaton

%3 WebSocket WebSocket WebSocketConnection WebSocketConnection WebSocket->WebSocketConnection

Conforms To

WebSocketConnection

Defines a websocket connection.

Initializers

init(url:​auto​Reply​ToPing:​connection​Queue:​additional​Headers:​)

public init(url: URL, autoReplyToPing: Bool = false, connectionQueue: DispatchQueue = .global(qos: .default), additionalHeaders: [String: String]? = [:])

Initialize a new websocket instance

Parameters

url URL

Websocket url to connect to

auto​Reply​ToPing Bool

Flag to indicate whether the instance should auto reply to ping messages

connection​Queue Dispatch​Queue

Queue on which the messages should be handled

additional​Headers [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(close​Code:​)

public func disconnect(closeCode: NWProtocolWebSocket.CloseCode = .protocolCode(.normalClosure))