Class WebsocketClient

java.lang.Object
ch.colabproject.colab.tests.ws.WebsocketClient

public class WebsocketClient extends Object
Author:
maxence
  • Method Details

    • onOpen

      public void onOpen(jakarta.websocket.Session session)
      Callback hook for Connection open events.
      Parameters:
      session - client session
    • onClose

      public void onClose(jakarta.websocket.Session session, jakarta.websocket.CloseReason reason)
      On close callback
      Parameters:
      session - the session
      reason - the reason
    • onRawMessage

      public void onRawMessage(String message)
      On message callback.
      Parameters:
      message - the message
    • sendMessage

      public void sendMessage(WsMessage message) throws IOException, jakarta.websocket.EncodeException
      Send a message.
      Parameters:
      message - the message to send
      Throws:
      IOException - failed to send the message
      jakarta.websocket.EncodeException - websocket error
    • getMessages

      public List<WsMessage> getMessages(int numberOfExpectedMessages, int timeout)
      wait until client received numberOfExpectedMessages messages.
      Parameters:
      numberOfExpectedMessages - number of expected messages
      timeout - stop waiting after this amount of second
      Returns:
      list of messages
    • getSessionId

      public WsSessionIdentifier getSessionId()
    • clearMessages

      public void clearMessages()
      Clear received messages
    • close

      public void close() throws IOException
      Throws:
      IOException
    • build

      public static WebsocketClient build(String endpoint) throws jakarta.websocket.DeploymentException, IOException, URISyntaxException, InterruptedException
      Throws:
      jakarta.websocket.DeploymentException
      IOException
      URISyntaxException
      InterruptedException