# WebSocket

Undocumented

- `CloseCode`

  Undocumented

  See more
- `ErrorDomain`

  Undocumented

- `callbackQueue`

  Undocumented

### Delegates

- `delegate`

  Responds to callback about new messages coming in over the WebSocket and also connection/disconnect messages.

  #### Declaration

  Swift

      public weak var delegate: WebSocketDelegate?

- `pongDelegate`

  Receives a callback for each pong message recived.

  #### Declaration

  Swift

      public weak var pongDelegate: WebSocketPongDelegate?

### Block based API.

- `onConnect`

  Undocumented

- `onDisconnect`

  Undocumented

- `onText`

  Undocumented

- `onData`

  Undocumented

- `onPong`

  Undocumented

- `headers`

  Undocumented

- `voipEnabled`

  Undocumented

- `disableSSLCertValidation`

  Undocumented

- `security`

  Undocumented

- `enabledSSLCipherSuites`

  Undocumented

- `origin`

  Undocumented

- `timeout`

  Undocumented

- `isConnected`

  Undocumented

- `currentURL`

  Undocumented

### Private

- `init(url:protocols:)`

  Used for setting protocols.

  #### Declaration

  Swift

      public init(url: URL, protocols: [String]? = nil)

- `init(url:writeQueueQOS:protocols:)`

  Undocumented

- `connect()`

  Connect to the WebSocket server on a background thread.

  #### Declaration

  Swift

      public func connect()

- `disconnect(forceTimeout:closeCode:)`

  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

      public func disconnect(forceTimeout: TimeInterval? = nil, closeCode: UInt16 = CloseCode.normal.rawValue)

  #### Parameters

  `forceTimeout` | Maximum time to wait for the server to close the socket.
  `closeCode` | The code to send on disconnect. The default is the normal close code for cleanly disconnecting a webSocket.

- `write(string:completion:)`

  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

      public func write(string: String, completion: (() -> ())? = nil)

  #### Parameters

  `str` | The string to write.
  `completion` | The (optional) completion handler.

- `write(data:completion:)`

  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

      public func write(data: Data, completion: (() -> ())? = nil)

  #### Parameters

  `data` | The data to write.
  `completion` | The (optional) completion handler.

- `write(ping:completion:)`

  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

      public func write(ping: Data, completion: (() -> ())? = nil)

- `stream(_:handle:)`

  Delegate for the stream methods. Processes incoming bytes

  #### Declaration

  Swift

      public func stream(_ aStream: Stream, handle eventCode: Stream.Event)

© 2017 . All rights reserved. (Last updated: 2017-06-08)

Generated by jazzy ♪♫ v0.7.4, a Realm project.