Class WebsocketClient


  • public class WebsocketClient
    extends Object
    Author:
    maxence
    • Method Detail

      • onOpen

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

        public void onClose​(javax.websocket.Session session,
                            javax.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,
                                javax.websocket.EncodeException
        Send a message.
        Parameters:
        message - the message to send
        Throws:
        IOException - failed to send the message
        javax.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
      • clearMessages

        public void clearMessages()
        Clear received messages