Package com.sun.faces.push
Class WebsocketPushContext
- java.lang.Object
-
- com.sun.faces.push.WebsocketPushContext
-
- All Implemented Interfaces:
PushContext
,Serializable
public class WebsocketPushContext extends Object implements PushContext
This is a concrete implementation of
PushContext
interface which is to be injected by@
Push
.- Since:
- 2.3
- Author:
- Bauke Scholtz
- See Also:
Push
, Serialized Form
-
-
Field Summary
-
Fields inherited from interface jakarta.faces.push.PushContext
ENABLE_WEBSOCKET_ENDPOINT_PARAM_NAME, URI_PREFIX, WEBSOCKET_ENDPOINT_PORT_PARAM_NAME
-
-
Constructor Summary
Constructors Constructor Description WebsocketPushContext(String channel, WebsocketSessionManager socketSessions, WebsocketUserManager socketUsers)
Creates a socket push context whereby the mutable map of session and view scope channel identifiers is referenced, so it's still available when another thread invokessend(Object)
during which the session and view scope is not necessarily active anymore.
-
Method Summary
All Methods Instance Methods Concrete 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>
.
-
-
-
Constructor Detail
-
WebsocketPushContext
public WebsocketPushContext(String channel, WebsocketSessionManager socketSessions, WebsocketUserManager socketUsers)
Creates a socket push context whereby the mutable map of session and view scope channel identifiers is referenced, so it's still available when another thread invokessend(Object)
during which the session and view scope is not necessarily active anymore.
-
-
Method Detail
-
send
public Set<Future<Void>> send(Object message)
Description copied from interface:PushContext
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>
.- Specified by:
send
in interfacePushContext
- 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
. - See Also:
RemoteEndpoint.Async.sendText(String)
-
send
public <S extends Serializable> Set<Future<Void>> send(Object message, S user)
Description copied from interface:PushContext
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>
.- Specified by:
send
in interfacePushContext
- 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
. - See Also:
RemoteEndpoint.Async.sendText(String)
-
send
public <S extends Serializable> Map<S,Set<Future<Void>>> send(Object message, Collection<S> users)
Description copied from interface:PushContext
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>
.- Specified by:
send
in interfacePushContext
- 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
. - See Also:
RemoteEndpoint.Async.sendText(String)
-
-