Package io.karatelabs.http
Class WsClient
java.lang.Object
io.karatelabs.http.WsClient
- All Implemented Interfaces:
io.karatelabs.common.Stoppable,AutoCloseable
Protocol-agnostic WebSocket client built on Netty.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static voidcloseAll()voidcloseNow()static WsClientconnect(WsClientOptions options) static WsClientstatic WsClientgetUri()booleanisOpen()voidvoidvoidvoidping()voidsend(byte[] binary) voidvoidstatic voidShut down the callback pool shared by every client that did not supply its own.voidstop()The graceful stop isclose()— a close frame to the peer, then the event loop wound down.voidwaitSync()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.karatelabs.common.Stoppable
lifecycleExecutor
-
Method Details
-
closeAll
public static void closeAll() -
shutdownCallbackExecutor
public static void shutdownCallbackExecutor()Shut down the callback pool shared by every client that did not supply its own. Deliberately not aKarateLifecycleregistrant: the pool is process-wide and outlives any one client, so draining it from a generic shutdown would silently drop the callbacks of clients connected afterwards. Its threads are daemons, so leaving it running never holds up JVM exit — call this only when no further websocket use is expected. -
connect
-
connect
-
connect
-
isOpen
public boolean isOpen() -
getUri
-
getNegotiatedSubprotocol
-
send
-
send
public void send(byte[] binary) -
send
-
sendAsync
-
onMessage
-
onClose
-
onError
-
lifecycleName
- Specified by:
lifecycleNamein interfaceio.karatelabs.common.Stoppable
-
lifecycleKind
- Specified by:
lifecycleKindin interfaceio.karatelabs.common.Stoppable
-
stop
public void stop()The graceful stop isclose()— a close frame to the peer, then the event loop wound down. Idempotent: a client already closed (or closed by the peer) does nothing.- Specified by:
stopin interfaceio.karatelabs.common.Stoppable
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceio.karatelabs.common.Stoppable
-
closeNow
public void closeNow() -
waitSync
public void waitSync() -
ping
public void ping()
-