io.quarkus.websockets.next.OnOpen Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-websockets-next Show documentation
Show all versions of quarkus-websockets-next Show documentation
Implementation of the WebSocket API with enhanced efficiency and usability
package io.quarkus.websockets.next;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import io.smallrye.common.annotation.Experimental;
/**
* {@link WebSocket} and {@link WebSocketClient} endpoint methods annotated with this annotation are invoked when a new
* connection is opened. An endpoint may declare at most one method annotated with this annotation.
*
* Execution model
*
*
* - Methods annotated with {@link io.smallrye.common.annotation.RunOnVirtualThread} are considered blocking and should be
* executed on a virtual thread.
* - Methods annotated with {@link io.smallrye.common.annotation.Blocking} are considered blocking and should be executed on a
* worker thread.
* - Methods annotated with {@link io.smallrye.common.annotation.NonBlocking} are considered non-blocking and should be
* executed on an event loop thread.
*
*
* Execution model for methods which don't declare any of the annotation listed above is derived from the return type:
*
*
* - Methods returning {@code void} are considered blocking and should be executed on a worker thread.
* - Methods returning {@link io.smallrye.mutiny.Uni} or {@link io.smallrye.mutiny.Multi} are 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 may accept the following parameters:
*
* - {@link WebSocketConnection}/{@link WebSocketClientConnection}; depending on the endpoint type
* - {@link HandshakeRequest}
* - {@link String} parameters annotated with {@link PathParam}
*
*/
@Retention(RUNTIME)
@Target(METHOD)
@Experimental("This API is experimental and may change in the future")
public @interface OnOpen {
/**
* Broadcasting is only supported for server endpoints annotated with {@link WebSocket}.
*
* @return {@code true} if all the connected clients should receive the objects emitted by the annotated method
* @see WebSocketConnection#broadcast()
*/
public boolean broadcast() default false;
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy