Package io.quarkus.websockets.next
Annotation Interface OnBinaryMessage
@Retention(RUNTIME)
@Target(METHOD)
@Experimental("This API is experimental and may change in the future")
public @interface OnBinaryMessage
WebSocket and WebSocketClient endpoint methods annotated with this annotation consume binary messages. An
endpoint may declare at most one method annotated with this annotation.
Execution model
- Methods annotated with
RunOnVirtualThreadare considered blocking and should be executed on a virtual thread. - Methods annotated with
Blockingare considered blocking and should be executed on a worker thread. - Methods annotated with
NonBlockingare considered non-blocking and should be executed on an event loop thread.
- Methods returning
voidare considered blocking and should be executed on a worker thread. - Methods returning
UniorMultiare considered non-blocking and should be executed on an event loop thread. - Methods returning any other type are considered blocking and should be executed on a worker thread.
Method parameters
The method must accept exactly one message parameter. A binary message is always represented as aBuffer. Therefore, the following conversion rules
apply. The types listed below are handled specifically. For all other types a BinaryMessageCodec is used to encode
and decode input and output messages. By default, the first input codec that supports the message type is used; codecs with
higher priority go first. However, a specific codec can be selected with codec() and outputCodec().
java.lang.Bufferis used as is,byte[]is encoded withBuffer.buffer(byte[])and decoded withBuffer.getBytes(),java.lang.Stringis encoded withBuffer.buffer(String)and decoded withBuffer.toString(),io.vertx.core.json.JsonObjectis encoded withJsonObject.toBuffer()and decoded withJsonObject(io.vertx.core.buffer.Buffer).io.vertx.core.json.JsonArrayis encoded withJsonArray.toBuffer()and decoded withJsonArray(io.vertx.core.buffer.Buffer).
The method may also accept the following parameters:
WebSocketConnection/WebSocketClientConnection; depending on the endpoint typeHandshakeRequestStringparameters annotated withPathParam
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanBroadcasting is only supported for server endpoints annotated withWebSocket.Class<? extends BinaryMessageCodec>The codec used for input messages.Class<? extends BinaryMessageCodec>The codec used for output messages.
-
Element Details
-
broadcast
boolean broadcastBroadcasting is only supported for server endpoints annotated withWebSocket.- Returns:
trueif all the connected clients should receive the objects returned by the annotated method- See Also:
- Default:
- false
-
codec
Class<? extends BinaryMessageCodec> codecThe codec used for input messages.By default, the first codec that supports the message type is used; codecs with higher priority go first. Note that, if specified, the codec is also used for output messages unless
outputCodec()returns a non-default value.- Default:
- io.quarkus.websockets.next.BinaryMessageCodec.class
-
outputCodec
Class<? extends BinaryMessageCodec> outputCodecThe codec used for output messages.By default, the same codec as for the input message is used.
- Default:
- io.quarkus.websockets.next.BinaryMessageCodec.class
-