Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.vertx.groovy.core.http
[Groovy] Class WebSocket

    java.lang.Object
      org.vertx.groovy.core.http.WebSocket

All Implemented Interfaces:
  ReadStream, WriteStream

    class WebSocket

Represents an HTML 5 Websocket

Instances of this class are created and provided to the handler of an HttpClient when a successful websocket connect attempt occurs.

On the server side, the subclass ServerWebSocket is used instead.

It implements both ReadStream and WriteStream so it can be used with Pump to pump data with flow control.

Instances of this class are not thread-safe

Authors:
  Tim Fox

Constructor Summary
`protected WebSocket(JWebSocket jWS)`

Method Summary
`void` | `close()` Close the websocket
`void` | `closedHandler(java.lang.Object handler)` Set a closed handler on the connection
`void` | `dataHandler(groovy.lang.Closure handler)` {@inheritDoc}
`void` | `drainHandler(groovy.lang.Closure handler)` {@inheritDoc}
`void` | `endHandler(groovy.lang.Closure endHandler)` {@inheritDoc}
`void` | `exceptionHandler(groovy.lang.Closure handler)` {@inheritDoc}
`java.lang.String` | `getBinaryHandlerID()` When a `Websocket` is created it automatically registers an event handler with the eventbus, the ID of that handler is given by `binaryHandlerID`.
`java.lang.String` | `getTextHandlerID()` When a `Websocket` is created it automatically registers an event handler with the eventbus, the ID of that handler is given by `textHandlerID`.
`boolean` | `isWriteQueueFull()` {@inheritDoc}
`void` | `leftShift(Buffer buff)` Same as writeBinaryFrame(Buffer)
`void` | `leftShift(java.lang.String str)` Same as writeTextFrame(String)
`void` | `pause()` {@inheritDoc}
`void` | `resume()` {@inheritDoc}
`void` | `setWriteQueueMaxSize(int maxSize)` {@inheritDoc}
`void` | `writeBinaryFrame(Buffer data)` Write `data` to the websocket as binary frame
`void` | `writeBuffer(Buffer data)` {@inheritDoc}
`void` | `writeTextFrame(java.lang.String str)` Write `str` to the websocket as text frame

Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Constructor Detail

### WebSocket

    protected WebSocket(JWebSocket jWS)

Method Detail

### close

    void close()

  Close the websocket

### closedHandler

    void closedHandler(java.lang.Object handler)

  Set a closed handler on the connection

### dataHandler

    void dataHandler(groovy.lang.Closure handler)

  {@inheritDoc}

### drainHandler

    void drainHandler(groovy.lang.Closure handler)

  {@inheritDoc}

### endHandler

    void endHandler(groovy.lang.Closure endHandler)

  {@inheritDoc}

### exceptionHandler

    void exceptionHandler(groovy.lang.Closure handler)

  {@inheritDoc}

### getBinaryHandlerID

    java.lang.String getBinaryHandlerID()

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

  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.

### getTextHandlerID

    java.lang.String getTextHandlerID()

  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.

### isWriteQueueFull

    boolean isWriteQueueFull()

  {@inheritDoc}

### leftShift

    void leftShift(Buffer buff)

  Same as writeBinaryFrame(Buffer)

### leftShift

    void leftShift(java.lang.String str)

  Same as writeTextFrame(String)

### pause

    void pause()

  {@inheritDoc}

### resume

    void resume()

  {@inheritDoc}

### setWriteQueueMaxSize

    void setWriteQueueMaxSize(int maxSize)

  {@inheritDoc}

### writeBinaryFrame

    void writeBinaryFrame(Buffer data)

  Write `data` to the websocket as binary frame

### writeBuffer

    void writeBuffer(Buffer data)

  {@inheritDoc}

### writeTextFrame

    void writeTextFrame(java.lang.String str)

  Write `str` to the websocket as text frame

Groovy Documentation