org.vertx.java.core.http.impl

## Class DefaultWebSocket

- java.lang.Object
- - org.vertx.java.core.http.WebSocket
  - - org.vertx.java.core.http.ServerWebSocket
    - - org.vertx.java.core.http.impl.DefaultWebSocket

All Implemented Interfaces:
  ReadStream, WriteStream

    public class DefaultWebSocket
    extends ServerWebSocket

### Field Summary

Fields
`protected boolean` `closed`

### Fields inherited from class org.vertx.java.core.http.ServerWebSocket

`path`

### Fields inherited from class org.vertx.java.core.http.WebSocket

`binaryHandlerID, textHandlerID`

### Constructor Summary

Constructors
`protected` `DefaultWebSocket(VertxInternal vertx, java.lang.String path, AbstractConnection conn, java.lang.Runnable connectRunnable)`

### Method Summary

Methods
`protected void` `checkClosed()`
`void` `close()` Close the websocket
`void` `closedHandler(Handler<java.lang.Void> handler)` Set a closed handler on the connection
`void` `dataHandler(Handler<Buffer> handler)` Set a data handler.
`void` `drainHandler(Handler<java.lang.Void> handler)` Set a drain handler on the stream.
`void` `endHandler(Handler<java.lang.Void> handler)` Set an end handler.
`void` `exceptionHandler(Handler<java.lang.Exception> handler)` Set an exception handler.
`void` `pause()` Pause the `ReadStream`.
`void` `reject()` Reject the WebSocket
`void` `resume()` Resume reading.
`void` `setWriteQueueMaxSize(int maxSize)` Set the maximum size of the write queue to `maxSize`.
`void` `writeBinaryFrame(Buffer data)` Write `data` to the websocket as a binary frame
`void` `writeBuffer(Buffer data)` Write some data to the stream.
`protected void` `writeFrame(WebSocketFrame frame)`
`boolean` `writeQueueFull()` This will return `true` if there are more bytes in the write queue than the value set using `WriteStream.setWriteQueueMaxSize(int)`
`void` `writeTextFrame(java.lang.String str)` Write `str` to the websocket as a text frame

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### closed

    protected boolean closed

### Constructor Detail

#### DefaultWebSocket

    protected DefaultWebSocket(VertxInternal vertx,
                    java.lang.String path,
                    AbstractConnection conn,
                    java.lang.Runnable connectRunnable)

### Method Detail

#### reject

    public void reject()

Description copied from class: `ServerWebSocket`
Reject the WebSocket

Calling this method from the websocketHandler 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.

Specified by:
  `reject` in class `ServerWebSocket`

#### writeBinaryFrame

    public void writeBinaryFrame(Buffer data)

Description copied from class: `WebSocket`
Write `data` to the websocket as a binary frame

Specified by:
  `writeBinaryFrame` in class `WebSocket`

#### writeTextFrame

    public void writeTextFrame(java.lang.String str)

Description copied from class: `WebSocket`
Write `str` to the websocket as a text frame

Specified by:
  `writeTextFrame` in class `WebSocket`

#### dataHandler

    public void dataHandler(Handler<Buffer> handler)

Description copied from interface: `ReadStream`
Set a data handler. As data is read, the handler will be called with the data.

#### endHandler

    public void endHandler(Handler<java.lang.Void> handler)

Description copied from interface: `ReadStream`
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.

#### exceptionHandler

    public void exceptionHandler(Handler<java.lang.Exception> handler)

Description copied from interface: `ReadStream`
Set an exception handler.

#### closedHandler

    public void closedHandler(Handler<java.lang.Void> handler)

Description copied from class: `WebSocket`
Set a closed handler on the connection

Specified by:
  `closedHandler` in class `WebSocket`

#### pause

    public void pause()

Description copied from interface: `ReadStream`
Pause the `ReadStream`. While the stream is paused, no data will be sent to the `dataHandler`

#### resume

    public void resume()

Description copied from interface: `ReadStream`
Resume reading. If the `ReadStream` has been paused, reading will recommence on it.

#### setWriteQueueMaxSize

    public void setWriteQueueMaxSize(int maxSize)

Description copied from interface: `WriteStream`
Set the maximum size of the write queue to `maxSize`. You will still be able to write to the stream even if there is more than `maxSize` bytes in the write queue. This is used as an indicator by classes such as `Pump` to provide flow control.

#### writeQueueFull

    public boolean writeQueueFull()

Description copied from interface: `WriteStream`
This will return `true` if there are more bytes in the write queue than the value set using `WriteStream.setWriteQueueMaxSize(int)`

#### writeBuffer

    public void writeBuffer(Buffer data)

Description copied from interface: `WriteStream`
Write some data to the stream. The data is put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the `WriteStream.writeQueueFull()` method before writing. This is done automatically if using a `Pump`.

#### drainHandler

    public void drainHandler(Handler<java.lang.Void> handler)

Description copied from interface: `WriteStream`
Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue has been reduced to maxSize / 2. See `Pump` for an example of this being used.

#### close

    public void close()

Description copied from class: `WebSocket`
Close the websocket

Specified by:
  `close` in class `WebSocket`

#### writeFrame

    protected void writeFrame(WebSocketFrame frame)

#### checkClosed

    protected void checkClosed()