Package jakarta.faces.push
Interface PushContext
-
- All Superinterfaces:
Serializable
public interface PushContext extends Serializable
CDI interface to send a message object to the push socket channel as identified by
@
Push
. This can be injected via@Push
in any container managed artifact in WAR.@Inject @Push private PushContext channelName;
For detailed usage instructions, see
@
Push
javadoc.- Since:
- 2.3
- See Also:
Push
-
-
Field Summary
Fields Modifier and Type Field Description static String
ENABLE_WEBSOCKET_ENDPOINT_PARAM_NAME
The boolean context parameter name to explicitly enable web socket endpoint during startup.static String
URI_PREFIX
The context-relative web socket URI prefix where the endpoint should listen on.static String
WEBSOCKET_ENDPOINT_PORT_PARAM_NAME
The integer context parameter name to specify the websocket endpoint port when it's different from HTTP port.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Set<Future<Void>>
send(Object message)
Send given message object to the push socket channel as identified by@
Push
.<S extends Serializable>
Map<S,Set<Future<Void>>>send(Object message, Collection<S> users)
Send given message object to the push socket channel as identified by@
Push
, targeted to the given users as identified by<f:websocket user>
.<S extends Serializable>
Set<Future<Void>>send(Object message, S user)
Send given message object to the push socket channel as identified by@
Push
, targeted to the given user as identified by<f:websocket user>
.
-
-
-
Field Detail
-
ENABLE_WEBSOCKET_ENDPOINT_PARAM_NAME
static final String ENABLE_WEBSOCKET_ENDPOINT_PARAM_NAME
The boolean context parameter name to explicitly enable web socket endpoint during startup.- See Also:
- Constant Field Values
-
WEBSOCKET_ENDPOINT_PORT_PARAM_NAME
static final String WEBSOCKET_ENDPOINT_PORT_PARAM_NAME
The integer context parameter name to specify the websocket endpoint port when it's different from HTTP port.- See Also:
- Constant Field Values
-
URI_PREFIX
static final String URI_PREFIX
The context-relative web socket URI prefix where the endpoint should listen on.- See Also:
- Constant Field Values
-
-
Method Detail
-
send
Set<Future<Void>> send(Object message)
Send given message object to the push socket channel as identified by@
Push
. The message object will be encoded as JSON and be available as first argument of the JavaScript listener function declared in<f:websocket onmessage>
.- Parameters:
message
- The push message object.- Returns:
- The results of the send operation. If it returns an empty set, then there was no open web socket session
associated with given socket channel. The returned futures will return
null
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
. - Throws:
IllegalArgumentException
- If given message object cannot be encoded as JSON.- See Also:
RemoteEndpoint.Async.sendText(String)
-
send
<S extends Serializable> Set<Future<Void>> send(Object message, S user)
Send given message object to the push socket channel as identified by@
Push
, targeted to the given user as identified by<f:websocket user>
. The message object will be encoded as JSON and be available as first argument of the JavaScript listener function declared in<f:websocket onmessage>
.- Type Parameters:
S
- The generic type of the user identifier.- Parameters:
message
- The push message object.user
- The user to which the push message object must be delivered to.- Returns:
- The results of the send operation. If it returns an empty set, then there was no open web socket session
associated with given socket channel and user. The returned futures will return
null
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
. - Throws:
IllegalArgumentException
- If given message object cannot be encoded as JSON.- See Also:
RemoteEndpoint.Async.sendText(String)
-
send
<S extends Serializable> Map<S,Set<Future<Void>>> send(Object message, Collection<S> users)
Send given message object to the push socket channel as identified by@
Push
, targeted to the given users as identified by<f:websocket user>
. The message object will be encoded as JSON and be available as first argument of the JavaScript listener function declared in<f:websocket onmessage>
.- Type Parameters:
S
- The generic type of the user identifier.- Parameters:
message
- The push message object.users
- The users to which the push message object must be delivered to.- Returns:
- The results of the send operation grouped by user. If it contains an empty set, then there was no open web
socket session associated with given socket channel and user. The returned futures will return
null
onFuture.get()
if the message was successfully delivered and otherwise throwExecutionException
. - Throws:
IllegalArgumentException
- If given message object cannot be encoded as JSON.- See Also:
RemoteEndpoint.Async.sendText(String)
-
-