# Class: WebSocket

## vertx-js/web_socket~ WebSocket

#### new WebSocket()

  Represents a client-side WebSocket.
  Source:
    - web_socket.js, line 33

### Methods

#### binaryHandlerID() → {string}

  When a `Websocket` is created it automatically registers an event handler with the event bus - the ID of that handler is given by this method.

  Given this ID, a different event loop can send a binary frame to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other WebSockets which are owned by different event loops.

  Source:
    - web_socket.js, line 65

  ##### Returns:

  the binary handler id
  Type
    string

#### close()

  Close the WebSocket.
  Source:
    - web_socket.js, line 97

#### closeHandler(handler) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - web_socket.js, line 316

  ##### Returns:

  Type
    WebSocket

#### drainHandler(handler) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - web_socket.js, line 246

  ##### Returns:

  Type
    WebSocket

#### endHandler(endHandler) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `endHandler` | function |

  Source:
    - web_socket.js, line 204

  ##### Returns:

  Type
    WebSocket

#### exceptionHandler(handler) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - web_socket.js, line 144

  ##### Returns:

  Type
    WebSocket

#### frameHandler(handler) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - web_socket.js, line 330

  ##### Returns:

  Type
    WebSocket

#### handler(handler) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - web_socket.js, line 160

  ##### Returns:

  Type
    WebSocket

#### localAddress() → {SocketAddress}

  Source:
    - web_socket.js, line 128

  ##### Returns:

  - the local address for this socket
  - Type
      SocketAddress

#### pause() → {WebSocket}

  Source:
    - web_socket.js, line 176

  ##### Returns:

  Type
    WebSocket

#### remoteAddress() → {SocketAddress}

  Source:
    - web_socket.js, line 111

  ##### Returns:

  - the remote address for this socket
  - Type
      SocketAddress

#### resume() → {WebSocket}

  Source:
    - web_socket.js, line 190

  ##### Returns:

  Type
    WebSocket

#### setWriteQueueMaxSize(maxSize) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `maxSize` | number |

  Source:
    - web_socket.js, line 232

  ##### Returns:

  Type
    WebSocket

#### textHandlerID() → {string}

  When a `Websocket` is created it automatically registers an event handler with the eventbus, the ID of that handler is given by `textHandlerID`.

  Given this ID, a different event loop can send a text frame to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other WebSockets which are owned by different event loops.

  Source:
    - web_socket.js, line 84

  ##### Returns:

  Type
    string

#### write(data) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `data` | Buffer |

  Source:
    - web_socket.js, line 218

  ##### Returns:

  Type
    WebSocket

#### writeBinaryMessage(data) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `data` | Buffer |

  Source:
    - web_socket.js, line 302

  ##### Returns:

  Type
    WebSocket

#### writeFinalBinaryFrame(data) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `data` | Buffer |

  Source:
    - web_socket.js, line 288

  ##### Returns:

  Type
    WebSocket

#### writeFinalTextFrame(text) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `text` | string |

  Source:
    - web_socket.js, line 274

  ##### Returns:

  Type
    WebSocket

#### writeFrame(frame) → {WebSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `frame` | WebSocketFrame |

  Source:
    - web_socket.js, line 260

  ##### Returns:

  Type
    WebSocket

#### writeQueueFull() → {boolean}

  This will return `true` if there are more bytes in the write queue than the value set using WebSocket#setWriteQueueMaxSize
  Source:
    - web_socket.js, line 46

  ##### Returns:

  true if write queue is full
  Type
    boolean