Class AgentSocket

java.lang.Object
org.java_websocket.WebSocketAdapter
org.java_websocket.AbstractWebSocket
org.java_websocket.client.WebSocketClient
com.ultikits.ultitools.utils.AgentSocket
All Implemented Interfaces:
AgentConnection.Handle, Runnable, org.java_websocket.WebSocket, org.java_websocket.WebSocketListener

final class AgentSocket extends org.java_websocket.client.WebSocketClient implements AgentConnection.Handle
One attempt's Java-WebSocket client for the UltiCloud /v1/agent socket (as of 6.3.1).

It decides nothing: it forwards open, text, refusal and close to the AgentConnection state machine through the attempt's AgentConnection.SocketEvents. A close whose upgrade was answered with a status other than 101 (recorded by StatusCapturingDraft) is reported as onUpgradeRefused; every other close as onClosed.

The TCP connect is bounded by the constructor's connect timeout (Java-WebSocket 1.6.0 has no setConnectTimeout); the library's ping control frames are disabled with setConnectionLostTimeout(0) because liveness is the application heartbeat's job (contract answer 2). The bearer exists only in the header map handed to the superclass: this class never logs it, keeps it in a field of its own, or prints it from toString.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
    Set when the state machine gave this attempt up; a late open is then closed at once.
     
    private final BiConsumer<Level,String>
     
    private static final int
     
     

    Fields inherited from class org.java_websocket.client.WebSocketClient

    uri

    Fields inherited from class org.java_websocket.AbstractWebSocket

    DEFAULT_READ_BUFFER_SIZE
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    (package private)
    AgentSocket(URI uri, Map<String,String> headers, int connectTimeoutMs, AgentConnection.SocketEvents events, BiConsumer<Level,String> log)
     
    private
    AgentSocket(URI uri, Map<String,String> headers, int connectTimeoutMs, AgentConnection.SocketEvents events, BiConsumer<Level,String> log, AtomicReference<UpgradeRejection> sink)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    closeAttempt(int code, String reason)
    Closes the attempt: the closing handshake when open, a forced close otherwise.
    private static String
     
    (package private) UpgradeRejection
     
    void
    onClose(int code, String reason, boolean remote)
     
    void
     
    void
    onMessage(String message)
     
    void
    onOpen(org.java_websocket.handshake.ServerHandshake handshake)
     
    boolean
     

    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, getReceiveBufferSize, isDaemon, isReuseAddr, isTcpNoDelay, setConnectionLostTimeout, setDaemon, setReceiveBufferSize, 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