- All Superinterfaces:
Serializable
- All Known Implementing Classes:
SocketPushContext
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 (not in EAR/EJB!).
@Inject @Push private PushContext channelName;
For detailed usage instructions, see Socket javadoc.
- Since:
- 2.3
- Author:
- Bauke Scholtz
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe context-relative web socket URI prefix where the endpoint should listen on. -
Method Summary
Modifier and TypeMethodDescriptionSend 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 given message object to the push socket channel as identified by@Push, targeted to the given user as identified by<o:socket user>.
-
Field Details
-
URI_PREFIX
The context-relative web socket URI prefix where the endpoint should listen on.- See Also:
-
-
Method Details
-
send
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>.- 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
nullonFuture.get()if the message was successfully delivered and otherwise throwExecutionException. - Throws:
IllegalArgumentException- If given message object cannot be encoded as JSON.- See Also:
-
send
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>.- 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
nullonFuture.get()if the message was successfully delivered and otherwise throwExecutionException. - Throws:
IllegalArgumentException- If given message object cannot be encoded as JSON.- See Also:
-
send
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>.- 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
nullonFuture.get()if the message was successfully delivered and otherwise throwExecutionException. - Throws:
IllegalArgumentException- If given message object cannot be encoded as JSON.- See Also:
-