# Class: ServerWebSocket

## vertx-js/server_web_socket~ ServerWebSocket

#### new ServerWebSocket()

Represents a server side WebSocket.

Source:
  - vertx-js/server_web_socket.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/server_web_socket.js, line 81

##### 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 ServerWebSocket#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/server_web_socket.js, line 150

##### Returns:

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

Type
  WebSocketBase

#### close()

Close the WebSocket.

Source:
  - vertx-js/server_web_socket.js, line 166

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 383

##### Returns:

Type
  ServerWebSocket

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 313

##### Returns:

Type
  ServerWebSocket

#### end(t)

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 46

#### endHandler(endHandler) → {ServerWebSocket}

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 271

##### Returns:

Type
  ServerWebSocket

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 211

##### Returns:

Type
  ServerWebSocket

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 397

##### Returns:

Type
  ServerWebSocket

#### handler(handler) → {ServerWebSocket}

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 227

##### Returns:

Type
  ServerWebSocket

#### headers() → {MultiMap}

Source:
  - vertx-js/server_web_socket.js, line 452

##### Returns:

the headers in the WebSocket handshake

Type
  MultiMap

#### localAddress() → {SocketAddress}

Source:
  - vertx-js/server_web_socket.js, line 195

##### Returns:

the local address for this socket

Type
  SocketAddress

#### path() → {string}

Source:
  - vertx-js/server_web_socket.js, line 426

##### Returns:

the WebSocket handshake path.

Type
  string

#### pause() → {ServerWebSocket}

Source:
  - vertx-js/server_web_socket.js, line 243

##### Returns:

Type
  ServerWebSocket

#### query() → {string}

Source:
  - vertx-js/server_web_socket.js, line 439

##### Returns:

the WebSocket handshake query string.

Type
  string

#### reject()

Reject the WebSocket.

Calling this method from the websocket handler when it is first passed to you gives you the opportunity to reject the websocket, which will cause the websocket handshake to fail by returning a 404 response code.

You might use this method, if for example you only want to accept WebSockets with a particular path.

Source:
  - vertx-js/server_web_socket.js, line 474

#### remoteAddress() → {SocketAddress}

Source:
  - vertx-js/server_web_socket.js, line 179

##### Returns:

the remote address for this socket

Type
  SocketAddress

#### resume() → {ServerWebSocket}

Source:
  - vertx-js/server_web_socket.js, line 257

##### Returns:

Type
  ServerWebSocket

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 299

##### Returns:

Type
  ServerWebSocket

#### 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/server_web_socket.js, line 100

##### 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/server_web_socket.js, line 131

##### Returns:

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

Type
  WebSocketBase

#### uri() → {string}

Source:
  - vertx-js/server_web_socket.js, line 413

##### Returns:

Type
  string

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 285

##### Returns:

Type
  ServerWebSocket

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 369

##### Returns:

Type
  ServerWebSocket

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 355

##### Returns:

Type
  ServerWebSocket

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

##### Parameters:

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

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

##### Returns:

Type
  ServerWebSocket

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

##### Parameters:

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

Source:
  - vertx-js/server_web_socket.js, line 327

##### Returns:

Type
  ServerWebSocket

#### writeQueueFull() → {boolean}

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

Source:
  - vertx-js/server_web_socket.js, line 62

##### 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/server_web_socket.js, line 115

##### Returns:

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

Type
  WebSocketBase