WebSocket

public class WebSocket: Hashable

WebSocket objects are bidirectional network streams that communicate over HTTP. RFC 6455.

  • url

    The URL as resolved by the constructor. This is always an absolute URL. Read only.

    Declaration

    Swift

    public var url : String
  • 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

    public var subProtocol : String
  • The compression options of the WebSocket.

    Declaration

    Swift

    public var compression : WebSocketCompression
  • Allow for Self-Signed SSL Certificates. Default is false.

    Declaration

    Swift

    public var allowSelfSignedSSL : Bool
  • The services of the WebSocket.

    Declaration

    Swift

    public var services : WebSocketService
  • The events of the WebSocket.

    Declaration

    Swift

    public var event : WebSocketEvents
  • The queue for firing off events. default is main_queue

    Declaration

    Swift

    public var eventQueue : dispatch_queue_t?
  • A WebSocketBinaryType value indicating the type of binary data being transmitted by the connection. Default is .UInt8Array.

    Declaration

    Swift

    public var binaryType : WebSocketBinaryType
  • The current state of the connection; this is one of the WebSocketReadyState constants. Read only.

    Declaration

    Swift

    public var readyState : WebSocketReadyState
  • 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. 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: NSURLRequest, subProtocols : [String] = [])
  • 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

    public func close(code : Int = 1000, reason : String = "Normal Closure")
  • Transmits message to the server over the WebSocket connection.

    :param: message The data to be sent to the server.

    Declaration

    Swift

    public func send(message : Any)
  • Transmits a ping to the server over the WebSocket connection.

    Declaration

    Swift

    public func ping()
  • Transmits a ping to the server over the WebSocket connection.

    :param: optional message The data to be sent to the server.

    Declaration

    Swift

    public func ping(message : Any)