Package: io.vertx.groovy.core.http

## [Groovy] Class ServerWebSocket

- io.vertx.groovy.core.http.ServerWebSocket

- All Implemented Interfaces and Traits:
    WebSocketBase

      @groovy.transform.CompileStatic
      class ServerWebSocket
      extends java.lang.Object

  Represents a server side WebSocket.

  Instances of this class are passed into a HttpServer.websocketHandler or provided when a WebSocket handshake is manually HttpServerRequest.upgradeed.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ServerWebSocket (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `java.lang.String` | `binaryHandlerID()` 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.
    `void` | `close()` Close the WebSocket.
    `ServerWebSocket` | `closeHandler(io.vertx.core.Handler<java.lang.Void> handler)`
    `ServerWebSocket` | `drainHandler(io.vertx.core.Handler<java.lang.Void> handler)`
    `void` | `end(Buffer t)` Same as WebSocketBase.end but writes some data to the stream before ending.
    `void` | `end()` Calls WebSocketBase.close
    `ServerWebSocket` | `endHandler(io.vertx.core.Handler<java.lang.Void> endHandler)`
    `ServerWebSocket` | `exceptionHandler(io.vertx.core.Handler<java.lang.Throwable> handler)`
    `ServerWebSocket` | `frameHandler(io.vertx.core.Handler<WebSocketFrame> handler)`
    `java.lang.Object` | `getDelegate()`
    `ServerWebSocket` | `handler(io.vertx.core.Handler<Buffer> handler)`
    `MultiMap` | `headers()` @return the headers in the WebSocket handshake
    `SocketAddress` | `localAddress()` @return the local address for this socket
    `java.lang.String` | `path()` @return the WebSocket handshake path.
    `ServerWebSocket` | `pause()`
    `java.lang.String` | `query()` @return the WebSocket handshake query string.
    `void` | `reject()` Reject the WebSocket.
    `SocketAddress` | `remoteAddress()` @return the remote address for this socket
    `ServerWebSocket` | `resume()`
    `ServerWebSocket` | `setWriteQueueMaxSize(int maxSize)`
    `java.lang.String` | `textHandlerID()` When a `Websocket` is created it automatically registers an event handler with the eventbus, the ID of that handler is given by `textHandlerID`.
    `java.lang.String` | `uri()`
    `ServerWebSocket` | `write(Buffer data)`
    `ServerWebSocket` | `writeBinaryMessage(Buffer data)`
    `ServerWebSocket` | `writeFinalBinaryFrame(Buffer data)`
    `ServerWebSocket` | `writeFinalTextFrame(java.lang.String text)`
    `ServerWebSocket` | `writeFrame(WebSocketFrame frame)`
    `boolean` | `writeQueueFull()` This will return `true` if there are more bytes in the write queue than the value set using ServerWebSocket.setWriteQueueMaxSize

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `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

    - #### ServerWebSocket(java.lang.Object delegate)

  - ### Method Detail

    - #### java.lang.String binaryHandlerID()

      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.

      Returns:
        the binary handler id

    - #### void close()

      Close the WebSocket.

    - #### ServerWebSocket closeHandler(io.vertx.core.Handler<java.lang.Void> handler)

    - #### ServerWebSocket drainHandler(io.vertx.core.Handler<java.lang.Void> handler)

    - #### void end(Buffer t)

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

      Parameters:
        t

    - #### void end()

      Calls WebSocketBase.close

    - #### ServerWebSocket endHandler(io.vertx.core.Handler<java.lang.Void> endHandler)

    - #### ServerWebSocket exceptionHandler(io.vertx.core.Handler<java.lang.Throwable> handler)

    - #### ServerWebSocket frameHandler(io.vertx.core.Handler<WebSocketFrame> handler)

    - #### java.lang.Object getDelegate()

    - #### ServerWebSocket handler(io.vertx.core.Handler<Buffer> handler)

    - #### MultiMap headers()

      Returns:
        the headers in the WebSocket handshake

    - #### SocketAddress localAddress()

      Returns:
        the local address for this socket

    - #### java.lang.String path()

      Returns:
        the WebSocket handshake path.

    - #### ServerWebSocket pause()

    - #### java.lang.String query()

      Returns:
        the WebSocket handshake query string.

    - #### void 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.

    - #### SocketAddress remoteAddress()

      Returns:
        the remote address for this socket

    - #### ServerWebSocket resume()

    - #### ServerWebSocket setWriteQueueMaxSize(int maxSize)

    - #### java.lang.String textHandlerID()

      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.

      Returns:

    - #### java.lang.String uri()

    - #### ServerWebSocket write(Buffer data)

    - #### ServerWebSocket writeBinaryMessage(Buffer data)

    - #### ServerWebSocket writeFinalBinaryFrame(Buffer data)

    - #### ServerWebSocket writeFinalTextFrame(java.lang.String text)

    - #### ServerWebSocket writeFrame(WebSocketFrame frame)

    - #### boolean writeQueueFull()

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

      Returns:
        true if write queue is full