Class WebSocketClient

  • All Implemented Interfaces:
    java.lang.Runnable, org.java_websocket.WebSocket, org.java_websocket.WebSocketListener

    public class WebSocketClient
    extends org.java_websocket.client.WebSocketClient
    Web socket client implementation that connects to a specify URI. Allows to provide a listener that will be called when a new message is received by the client.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.java_websocket.WebSocket

        org.java_websocket.WebSocket.READYSTATE, org.java_websocket.WebSocket.Role
    • Field Summary

      • Fields inherited from class org.java_websocket.client.WebSocketClient

        uri
      • Fields inherited from interface org.java_websocket.WebSocket

        DEFAULT_PORT, DEFAULT_WSS_PORT
    • Constructor Summary

      Constructors 
      Constructor Description
      WebSocketClient​(java.net.URI serverUri)  
      WebSocketClient​(java.net.URI serverUri, java.util.Map<java.lang.String,​java.lang.String> httpHeaders)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void onClose​(int code, java.lang.String reason, boolean remote)  
      void onError​(java.lang.Exception e)  
      void onMessage​(java.lang.String s)  
      void onOpen​(org.java_websocket.handshake.ServerHandshake serverHandshake)  
      void setListener​(WebSocketListener listener)
      Set a listener that will be called when a new message is received by the client.
      • Methods inherited from class org.java_websocket.client.WebSocketClient

        close, close, close, closeBlocking, closeConnection, connect, connectBlocking, getAttachment, getConnection, getConnections, getDraft, getLocalSocketAddress, getLocalSocketAddress, getReadyState, getRemoteSocketAddress, getRemoteSocketAddress, getResourceDescriptor, getSocket, getURI, hasBufferedData, isClosed, isClosing, isConnecting, isFlushAndClose, isOpen, onCloseInitiated, onClosing, onFragment, onMessage, onWebsocketClose, onWebsocketCloseInitiated, onWebsocketClosing, onWebsocketError, onWebsocketMessage, onWebsocketMessage, onWebsocketMessageFragment, onWebsocketOpen, onWriteDemand, reconnect, reconnectBlocking, run, send, send, send, sendFragmentedFrame, sendFrame, sendFrame, sendPing, setAttachment, setProxy, setSocket
      • Methods inherited from class org.java_websocket.AbstractWebSocket

        getConnectionLostTimeout, isReuseAddr, isTcpNoDelay, setConnectionLostTimeout, setReuseAddr, setTcpNoDelay, startConnectionLostTimer, stopConnectionLostTimer
      • Methods inherited from class org.java_websocket.WebSocketAdapter

        onWebsocketHandshakeReceivedAsClient, onWebsocketHandshakeReceivedAsServer, onWebsocketHandshakeSentAsClient, onWebsocketPing, onWebsocketPong
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WebSocketClient

        public WebSocketClient​(java.net.URI serverUri)
      • WebSocketClient

        public WebSocketClient​(java.net.URI serverUri,
                               java.util.Map<java.lang.String,​java.lang.String> httpHeaders)
    • Method Detail

      • onOpen

        public void onOpen​(org.java_websocket.handshake.ServerHandshake serverHandshake)
        Specified by:
        onOpen in class org.java_websocket.client.WebSocketClient
      • onMessage

        public void onMessage​(java.lang.String s)
        Specified by:
        onMessage in class org.java_websocket.client.WebSocketClient
      • onClose

        public void onClose​(int code,
                            java.lang.String reason,
                            boolean remote)
        Specified by:
        onClose in class org.java_websocket.client.WebSocketClient
      • onError

        public void onError​(java.lang.Exception e)
        Specified by:
        onError in class org.java_websocket.client.WebSocketClient
      • setListener

        public void setListener​(WebSocketListener listener)
        Set a listener that will be called when a new message is received by the client.
        Parameters:
        listener - WebSocket listener