WebSocket
open class WebSocket : NSObject, StreamDelegate, WebSocketClient, WSStreamDelegate
Undocumented
-
Undocumented
See moreDeclaration
Swift
public enum OpCode : UInt8 -
Undocumented
Declaration
Swift
public static let ErrorDomain = "WebSocket" -
Undocumented
Declaration
Swift
public var callbackQueue = DispatchQueue.main
-
Undocumented
See moreDeclaration
Swift
public class WSResponse
-
Responds to callback about new messages coming in over the WebSocket and also connection/disconnect messages.
Declaration
Swift
public weak var delegate: WebSocketDelegate? -
The optional advanced delegate can be used instead of of the delegate
Declaration
Swift
public weak var advancedDelegate: WebSocketAdvancedDelegate? -
Receives a callback for each pong message recived.
Declaration
Swift
public weak var pongDelegate: WebSocketPongDelegate? -
Undocumented
Declaration
Swift
public var onConnect: (() -> Void)? -
Undocumented
Declaration
Swift
public var onDisconnect: ((Error?) -> Void)? -
Undocumented
Declaration
Swift
public var onText: ((String) -> Void)? -
Undocumented
Declaration
Swift
public var onData: ((Data) -> Void)? -
Undocumented
Declaration
Swift
public var onPong: ((Data?) -> Void)? -
Undocumented
Declaration
Swift
public var onHttpResponseHeaders: (([String: String]) -> Void)? -
Undocumented
Declaration
Swift
public var disableSSLCertValidation = false -
Undocumented
Declaration
Swift
public var overrideTrustHostname = false -
Undocumented
Declaration
Swift
public var desiredTrustHostname: String? = nil -
Undocumented
Declaration
Swift
public var sslClientCertificate: SSLClientCertificate? = nil -
Undocumented
Declaration
Swift
public var enableCompression = true -
Undocumented
Declaration
Swift
public var security: SSLTrustValidator? -
Undocumented
Declaration
Swift
public var enabledSSLCipherSuites: [SSLCipherSuite]? -
Undocumented
Declaration
Swift
public var isConnected: Bool -
Undocumented
Declaration
Swift
public var request: URLRequest -
Undocumented
Declaration
Swift
public var currentURL: URL -
Undocumented
Declaration
Swift
public var respondToPingWithPong: Bool = true
-
Used for setting protocols.
Declaration
Swift
public init(request: URLRequest, protocols: [String]? = nil, stream: WSStream = FoundationStream()) -
Undocumented
Declaration
Swift
public convenience init(url: URL, protocols: [String]? = nil) -
Undocumented
Declaration
Swift
public convenience init(url: URL, writeQueueQOS: QualityOfService, protocols: [String]? = nil) -
Connect to the WebSocket server on a background thread.
Declaration
Swift
open func connect() -
Disconnect from the server. I send a Close control frame to the server, then expect the server to respond with a Close control frame and close the socket from its end. I notify my delegate once the socket has been closed.
If you supply a non-nil
forceTimeout, I wait at most that long (in seconds) for the server to close the socket. After the timeout expires, I close the socket and notify my delegate.If you supply a zero (or negative)
forceTimeout, I immediately close the socket (without sending a Close control frame) and notify my delegate.Declaration
Swift
open func disconnect(forceTimeout: TimeInterval? = nil, closeCode: UInt16 = CloseCode.normal.rawValue)Parameters
forceTimeoutMaximum time to wait for the server to close the socket.
closeCodeThe code to send on disconnect. The default is the normal close code for cleanly disconnecting a webSocket.
-
Write a string to the websocket. This sends it as a text frame.
If you supply a non-nil completion block, I will perform it when the write completes.
Declaration
Swift
open func write(string: String, completion: (() -> ())? = nil)Parameters
stringThe string to write.
completionThe (optional) completion handler.
-
Write binary data to the websocket. This sends it as a binary frame.
If you supply a non-nil completion block, I will perform it when the write completes.
Declaration
Swift
open func write(data: Data, completion: (() -> ())? = nil)Parameters
dataThe data to write.
completionThe (optional) completion handler.
-
Write a ping to the websocket. This sends it as a control frame. Yodel a sound to the planet. This sends it as an astroid. http://youtu.be/Eu5ZJELRiJ8?t=42s
Declaration
Swift
open func write(ping: Data, completion: (() -> ())? = nil) -
Write a pong to the websocket. This sends it as a control frame. Respond to a Yodel.
Declaration
Swift
open func write(pong: Data, completion: (() -> ())? = nil) -
Delegate for the stream methods. Processes incoming bytes
Declaration
Swift
public func newBytesInStream() -
Undocumented
Declaration
Swift
public func streamDidError(error: Error?)
View on GitHub
Install in Dash