Package io.karatelabs.http
Class WsConnection
java.lang.Object
io.karatelabs.http.WsConnection
WebSocket connection wrapping a Netty channel.
Provides methods to send messages, register callbacks for incoming messages,
and manage the connection lifecycle.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the WebSocket connection with a normal closure.voidClose the WebSocket connection with a specific status code and reason.booleanisOpen()voidRegister a callback for incoming binary messages.voidRegister a callback for when the connection closes.voidRegister a callback for incoming text messages.voidSend a text message.voidsendBytes(byte[] data) Send a binary message.
-
Method Details
-
send
Send a text message. -
sendBytes
public void sendBytes(byte[] data) Send a binary message. -
onMessage
Register a callback for incoming text messages. -
onBinary
Register a callback for incoming binary messages. -
onClose
Register a callback for when the connection closes. -
close
public void close()Close the WebSocket connection with a normal closure. -
close
Close the WebSocket connection with a specific status code and reason. -
isOpen
public boolean isOpen()
-