# Class: WebSocketBase

## vertx-js/web_socket_base~ WebSocketBase

#### new WebSocketBase()

Base WebSocket implementation.

Source:
  - vertx-js/web_socket_base.js, line 34

### 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:
  - vertx-js/web_socket_base.js, line 198

##### Returns:

the binary handler id

Type
  string

#### binaryMessageHandler(handler) → {WebSocketBase}

Set a binary message handler on the connection. This handler serves a similar purpose to WebSocketBase#handler except that if a message comes into the socket in multiple frames, the data from the frames will be aggregated into a single buffer before calling the handler (using WebSocketFrame#isFinal to find the boundaries).

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 360

##### Returns:

a reference to this, so the API can be used fluently

Type
  WebSocketBase

#### close()

Close the WebSocket.

Source:
  - vertx-js/web_socket_base.js, line 376

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

Set a close handler. This will be called when the WebSocket is closed.

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 308

##### Returns:

a reference to this, so the API can be used fluently

Type
  WebSocketBase

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

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 178

##### Returns:

Type
  WebSocketBase

#### end(t)

Same as WebSocketBase#end but writes some data to the stream before ending.

##### Parameters:

Name | Type | Description
--- | --- | ---
`t` | Buffer |

Source:
  - vertx-js/web_socket_base.js, line 47

#### endHandler(endHandler) → {WebSocketBase}

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 136

##### Returns:

Type
  WebSocketBase

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

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 76

##### Returns:

Type
  WebSocketBase

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

Set a frame handler on the connection. This handler will be called when frames are read on the connection.

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 323

##### Returns:

a reference to this, so the API can be used fluently

Type
  WebSocketBase

#### handler(handler) → {WebSocketBase}

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 92

##### Returns:

Type
  WebSocketBase

#### localAddress() → {SocketAddress}

Source:
  - vertx-js/web_socket_base.js, line 405

##### Returns:

the local address for this socket

Type
  SocketAddress

#### pause() → {WebSocketBase}

Source:
  - vertx-js/web_socket_base.js, line 108

##### Returns:

Type
  WebSocketBase

#### remoteAddress() → {SocketAddress}

Source:
  - vertx-js/web_socket_base.js, line 389

##### Returns:

the remote address for this socket

Type
  SocketAddress

#### resume() → {WebSocketBase}

Source:
  - vertx-js/web_socket_base.js, line 122

##### Returns:

Type
  WebSocketBase

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

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 164

##### Returns:

Type
  WebSocketBase

#### 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:
  - vertx-js/web_socket_base.js, line 217

##### Returns:

Type
  string

#### textMessageHandler(handler) → {WebSocketBase}

Set a text message handler on the connection. This handler will be called similar to the , but the buffer will be converted to a String first

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 341

##### Returns:

a reference to this, so the API can be used fluently

Type
  WebSocketBase

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

##### Parameters:

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

Source:
  - vertx-js/web_socket_base.js, line 150

##### Returns:

Type
  WebSocketBase

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

Writes a (potentially large) piece of binary data to the connection. This data might be written as multiple frames if it exceeds the maximum WebSocket frame size.

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Buffer | the data to write

Source:
  - vertx-js/web_socket_base.js, line 277

##### Returns:

a reference to this, so the API can be used fluently

Type
  WebSocketBase

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

Write a final WebSocket binary frame to the connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Buffer | The data to write

Source:
  - vertx-js/web_socket_base.js, line 261

##### Returns:

a reference to this, so the API can be used fluently

Type
  WebSocketBase

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

Write a final WebSocket text frame to the connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`text` | string | The text to write

Source:
  - vertx-js/web_socket_base.js, line 246

##### Returns:

a reference to this, so the API can be used fluently

Type
  WebSocketBase

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

Write a WebSocket frame to the connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`frame` | WebSocketFrame | the frame to write

Source:
  - vertx-js/web_socket_base.js, line 231

##### Returns:

a reference to this, so the API can be used fluently

Type
  WebSocketBase

#### writeQueueFull() → {boolean}

This will return `true` if there are more bytes in the write queue than the value set using WebSocketBase#setWriteQueueMaxSize

Source:
  - vertx-js/web_socket_base.js, line 63

##### Returns:

true if write queue is full

Type
  boolean

#### writeTextMessage(text) → {WebSocketBase}

Writes a (potentially large) piece of text data to the connection. This data might be written as multiple frames if it exceeds the maximum WebSocket frame size.

##### Parameters:

Name | Type | Description
--- | --- | ---
`text` | string | the data to write

Source:
  - vertx-js/web_socket_base.js, line 293

##### Returns:

a reference to this, so the API can be used fluently

Type
  WebSocketBase