# Uses of Interface
java.net.http.WebSocket

Packages that use WebSocket
Package
Description
java.net.http
HTTP Client and WebSocket APIs

- ## Uses of WebSocket in java.net.http

  Methods in java.net.http that return types with arguments of type WebSocket
  Modifier and Type
  Method
  Description
  `CompletableFuture<WebSocket>`
  WebSocket.Builder.`buildAsync(URI uri, WebSocket.Listener listener)`
  Builds a `WebSocket` connected to the given `URI` and associated with the given `Listener`.
  `CompletableFuture<WebSocket>`
  WebSocket.`sendBinary(ByteBuffer data, boolean last)`
  Sends binary data with bytes from the given buffer.
  `CompletableFuture<WebSocket>`
  WebSocket.`sendClose(int statusCode, String reason)`
  Initiates an orderly closure of this WebSocket's output by sending a Close message with the given status code and the reason.
  `CompletableFuture<WebSocket>`
  WebSocket.`sendPing(ByteBuffer message)`
  Sends a Ping message with bytes from the given buffer.
  `CompletableFuture<WebSocket>`
  WebSocket.`sendPong(ByteBuffer message)`
  Sends a Pong message with bytes from the given buffer.
  `CompletableFuture<WebSocket>`
  WebSocket.`sendText(CharSequence data, boolean last)`
  Sends textual data with characters from the given character sequence.
  Methods in java.net.http with parameters of type WebSocket
  Modifier and Type
  Method
  Description
  `default CompletionStage<?>`
  WebSocket.Listener.`onBinary(WebSocket webSocket, ByteBuffer data, boolean last)`
  A binary data has been received.
  `default CompletionStage<?>`
  WebSocket.Listener.`onClose(WebSocket webSocket, int statusCode, String reason)`
  Receives a Close message indicating the WebSocket's input has been closed.
  `default void`
  WebSocket.Listener.`onError(WebSocket webSocket, Throwable error)`
  An error has occurred.
  `default void`
  WebSocket.Listener.`onOpen(WebSocket webSocket)`
  A `WebSocket` has been connected.
  `default CompletionStage<?>`
  WebSocket.Listener.`onPing(WebSocket webSocket, ByteBuffer message)`
  A Ping message has been received.
  `default CompletionStage<?>`
  WebSocket.Listener.`onPong(WebSocket webSocket, ByteBuffer message)`
  A Pong message has been received.
  `default CompletionStage<?>`
  WebSocket.Listener.`onText(WebSocket webSocket, CharSequence data, boolean last)`
  A textual data has been received.