WebSocket
@objcMembers
open class WebSocket : NSObject
WebSocket objects are bidirectional network streams that communicate over HTTP. RFC 6455.
-
Declaration
Swift
open override var hash: Int { get } -
Declaration
Swift
open override func isEqual(_ other: Any?) -> Bool -
Create a WebSocket connection to a URL; this should be the URL to which the WebSocket server will respond.
Declaration
Swift
public convenience init(_ url: String) -
Create a WebSocket connection to a URL; this should be the URL to which the WebSocket server will respond.
Declaration
Swift
public convenience init(url: URL) -
Create a WebSocket connection to a URL; this should be the URL to which the WebSocket server will respond. Also include a list of protocols.
Declaration
Swift
public convenience init(_ url: String, subProtocols: [String]) -
Create a WebSocket connection to a URL; this should be the URL to which the WebSocket server will respond. Also include a protocol.
Declaration
Swift
public convenience init(_ url: String, subProtocol: String) -
Create a WebSocket connection from an NSURLRequest; Also include a list of protocols.
Declaration
Swift
public init(request: URLRequest, subProtocols: [String] = []) -
Create a WebSocket object with a deferred connection; the connection is not opened until the .open() method is called.
Declaration
Swift
public convenience override init() -
The URL as resolved by the constructor. This is always an absolute URL. Read only.
Declaration
Swift
open var url: String { get } -
A string indicating the name of the sub-protocol the server selected; this will be one of the strings specified in the protocols parameter when creating the WebSocket object.
Declaration
Swift
open var subProtocol: String { get } -
The compression options of the WebSocket.
Declaration
Swift
open var compression: WebSocketCompression { get set } -
Allow for Self-Signed SSL Certificates. Default is false.
Declaration
Swift
open var allowSelfSignedSSL: Bool { get set } -
The services of the WebSocket.
Declaration
Swift
open var services: WebSocketService { get set } -
The events of the WebSocket.
Declaration
Swift
open var event: WebSocketEvents { get set } -
The queue for firing off events. default is main_queue
Declaration
Swift
open var eventQueue: DispatchQueue? { get set } -
A WebSocketBinaryType value indicating the type of binary data being transmitted by the connection. Default is .UInt8Array.
Declaration
Swift
open var binaryType: WebSocketBinaryType { get set } -
The current state of the connection; this is one of the WebSocketReadyState constants. Read only.
Declaration
Swift
open var readyState: WebSocketReadyState { get } -
Opens a deferred or closed WebSocket connection to a URL; this should be the URL to which the WebSocket server will respond.
Declaration
Swift
open func open(_ url: String) -
Opens a deferred or closed WebSocket connection to a URL; this should be the URL to which the WebSocket server will respond.
Declaration
Swift
open func open(nsurl url: URL) -
Opens a deferred or closed WebSocket connection to a URL; this should be the URL to which the WebSocket server will respond. Also include a list of protocols.
Declaration
Swift
open func open(_ url: String, subProtocols: [String]) -
Opens a deferred or closed WebSocket connection to a URL; this should be the URL to which the WebSocket server will respond. Also include a protocol.
Declaration
Swift
open func open(_ url: String, subProtocol: String) -
Opens a deferred or closed WebSocket connection from an NSURLRequest; Also include a list of protocols.
Declaration
Swift
open func open(request: URLRequest, subProtocols: [String] = []) -
Opens a closed WebSocket connection from an NSURLRequest; Uses the same request and protocols as previously closed WebSocket
Declaration
Swift
open func open() -
Closes the WebSocket connection or connection attempt, if any. If the connection is already closed or in the state of closing, this method does nothing.
:param: code An integer indicating the status code explaining why the connection is being closed. If this parameter is not specified, a default value of 1000 (indicating a normal closure) is assumed. :param: reason A human-readable string explaining why the connection is closing. This string must be no longer than 123 bytes of UTF-8 text (not characters).
Declaration
Swift
open func close(_ code: Int = 1000, reason: String = "Normal Closure") -
Transmits message to the server over the WebSocket connection.
:param: message The message to be sent to the server.
Declaration
Swift
open func send(_ message: Any) -
Transmits a ping to the server over the WebSocket connection.
:param: optional message The data to be sent to the server.
Declaration
Swift
open func ping(_ message: Any) -
Transmits a ping to the server over the WebSocket connection.
Declaration
Swift
open func ping() -
The events of the WebSocket using a delegate.
Declaration
Swift
@objc public var delegate: WebSocketDelegate? { get set } -
Transmits message to the server over the WebSocket connection.
:param: text The message (string) to be sent to the server.
Declaration
Swift
@objc public func send(text: String) -
Transmits message to the server over the WebSocket connection.
:param: data The message (binary) to be sent to the server.
Declaration
Swift
@objc public func send(data: Data)
WebSocket Class Reference