Package jakarta.websocket
Annotation Interface ClientEndpoint
The ClientEndpoint annotation a class level annotation is used to denote that a POJO is a web socket client and can
be deployed as such. Similar to
jakarta.websocket.server.ServerEndpoint
, POJOs that are annotated with this
annotation can have methods that, using the web socket method level annotations, are web socket lifecycle methods.
For example:
@ClientEndpoint(subprotocols="chat")
public class HelloServer {
@OnMessage
public void processMessageFromServer(String message, Session session) {
System.out.println("Message came from the server ! " + message);
}
}
- Author:
- dannycoward
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionClass
<? extends ClientEndpointConfig.Configurator> An optional custom configurator class that the developer would like to use to provide custom configuration of new instances of this endpoint.The array of Java classes that are to act as Decoders for messages coming into the client.The array of Java classes that are to act as Encoders for messages sent by the client.String[]
The names of the subprotocols this client supports.
-
Element Details
-
subprotocols
String[] subprotocolsThe names of the subprotocols this client supports.- Returns:
- the array of names of the subprotocols.
- Default:
{}
-
decoders
The array of Java classes that are to act as Decoders for messages coming into the client.- Returns:
- the array of decoders.
- Default:
{}
-
encoders
The array of Java classes that are to act as Encoders for messages sent by the client.- Returns:
- the array of decoders.
- Default:
{}
-
configurator
Class<? extends ClientEndpointConfig.Configurator> configuratorAn optional custom configurator class that the developer would like to use to provide custom configuration of new instances of this endpoint. The implementation creates a new instance of the configurator per logical endpoint.- Returns:
- the custom configurator class, or ClientEndpointConfigurator.class if none was provided in the annotation.
- Default:
jakarta.websocket.ClientEndpointConfig.Configurator.class
-