- java.lang.Object
-
- org.omnifaces.cdi.push.SocketPushContext
-
- All Implemented Interfaces:
Serializable
,PushContext
public class SocketPushContext 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 org.omnifaces.cdi.PushContext
URI_PREFIX
-
-
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<o:socket 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<o:socket user>
.
-
-
-
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<o:socket 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:
Json.encode(Object)
,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<o:socket user>
. The message object will be encoded as JSON and be available as first argument of the JavaScript listener function declared in<o:socket 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:
Json.encode(Object)
,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<o:socket user>
. The message object will be encoded as JSON and be available as first argument of the JavaScript listener function declared in<o:socket 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:
Json.encode(Object)
,RemoteEndpoint.Async.sendText(String)
-
-