Class ClientSocket

java.lang.Object
org.java_websocket.WebSocketAdapter
org.java_websocket.AbstractWebSocket
org.java_websocket.client.WebSocketClient
dev.adlin.vts4j.core.socket.ClientSocket
All Implemented Interfaces:
Runnable, org.java_websocket.WebSocket, org.java_websocket.WebSocketListener

public class ClientSocket extends org.java_websocket.client.WebSocketClient
  • Field Summary

    Fields inherited from class org.java_websocket.client.WebSocketClient

    uri
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClientSocket(URI serverUri)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onClose(int code, String reason, boolean remote)
     
    void
     
    void
    onMessage(String message)
     
    void
    onOpen(org.java_websocket.handshake.ServerHandshake handshake)
     
    void
    Sets the handler to be called when the WebSocket connection is closed.
    void
    Sets the handler to be called when an error occurs in the WebSocket connection.
    void
    Sets the handler to be called when a message is received from the WebSocket.
    void
    setOpenHandler(Consumer<org.java_websocket.handshake.ServerHandshake> onOpen)
    Sets the handler to be called when the WebSocket connection is opened.

    Methods inherited from class org.java_websocket.client.WebSocketClient

    addHeader, clearHeaders, close, close, close, closeBlocking, closeConnection, connect, connectBlocking, connectBlocking, getAttachment, getConnection, getConnections, getDraft, getLocalSocketAddress, getLocalSocketAddress, getProtocol, getReadyState, getRemoteSocketAddress, getRemoteSocketAddress, getResourceDescriptor, getSocket, getSSLSession, getURI, hasBufferedData, hasSSLSupport, isClosed, isClosing, isFlushAndClose, isOpen, onCloseInitiated, onClosing, onMessage, onSetSSLParameters, onWebsocketClose, onWebsocketCloseInitiated, onWebsocketClosing, onWebsocketError, onWebsocketMessage, onWebsocketMessage, onWebsocketOpen, onWriteDemand, reconnect, reconnectBlocking, removeHeader, run, send, send, send, sendFragmentedFrame, sendFrame, sendFrame, sendPing, setAttachment, setDnsResolver, setProxy, setSocket, setSocketFactory

    Methods inherited from class org.java_websocket.AbstractWebSocket

    getConnectionLostTimeout, isReuseAddr, isTcpNoDelay, setConnectionLostTimeout, setReuseAddr, setTcpNoDelay, startConnectionLostTimer, stopConnectionLostTimer

    Methods inherited from class org.java_websocket.WebSocketAdapter

    onPreparePing, onWebsocketHandshakeReceivedAsClient, onWebsocketHandshakeReceivedAsServer, onWebsocketHandshakeSentAsClient, onWebsocketPing, onWebsocketPong

    Methods inherited from class java.lang.Object

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

    • ClientSocket

      public ClientSocket(URI serverUri)
  • Method Details

    • onOpen

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

      public void onMessage(String message)
      Specified by:
      onMessage in class org.java_websocket.client.WebSocketClient
    • onClose

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

      public void onError(Exception ex)
      Specified by:
      onError in class org.java_websocket.client.WebSocketClient
    • setOpenHandler

      public void setOpenHandler(Consumer<org.java_websocket.handshake.ServerHandshake> onOpen)
      Sets the handler to be called when the WebSocket connection is opened. The provided Consumer will receive a ServerHandshake object containing details about the handshake.
      Parameters:
      onOpen - The handler to be called on connection open. Receives a ServerHandshake object.
    • setMessageHandler

      public void setMessageHandler(Consumer<String> messageHandler)
      Sets the handler to be called when a message is received from the WebSocket. The provided Consumer will receive the message as a String.
      Parameters:
      messageHandler - The handler to be called on message receipt. Receives the message as a String.
    • setCloseHandler

      public void setCloseHandler(Consumer<CloseReason> onClose)
      Sets the handler to be called when the WebSocket connection is closed. The provided Consumer will receive a CloseReason object containing details about the closure.
      Parameters:
      onClose - The handler to be called on connection close. Receives a CloseReason object.
    • setErrorHandler

      public void setErrorHandler(Consumer<Throwable> onError)
      Sets the handler to be called when an error occurs in the WebSocket connection. The provided Consumer will receive a Throwable object representing the error.
      Parameters:
      onError - The handler to be called on error. Receives a Throwable object.