Class WebSocketPair

java.lang.Object
dev.gmitch215.bytebox.socket.WebSocketPair

public final class WebSocketPair extends Object
The two ends of a WebSocket the Worker itself creates.

Accepting a connection means making a pair, keeping the server end, and answering the request with the client end and status 101. The client end is never used from Java: it goes back to whoever asked.

 WebSocketPair pair = WebSocketPair.create();
 state.acceptWebSocket(pair.server());
 return Bytebox.upgrade(pair.client());
Since:
1.0.0
  • Method Details

    • create

      public static WebSocketPair create()
      Returns a new pair.
      Returns:
      a new pair
    • client

      public WebSocket client()
      Returns the end that goes back to the client, in a 101 response.
      Returns:
      the end that goes back to the client, in a 101 response
    • server

      public WebSocket server()
      Returns the end this Worker keeps.
      Returns:
      the end this Worker keeps