Top Description Fields Constructors Methods
com.sun.faces.push

public Class WebsocketPushContext

extends Object
implements PushContext
Class Inheritance
All Implemented Interfaces
javax.faces.push.PushContext, java.io.Serializable
Static Imports
com.sun.faces.push.WebsocketChannelManager.EMPTY_SCOPE, .WebsocketChannelManager.getChannelId, .WebsocketChannelManager.getSessionScope, .WebsocketChannelManager.getViewScope, java.util.Collections.singleton

This is a concrete implementation of PushContext interface which is to be injected by @Push.

Author
Bauke Scholtz
Since
2.3
See Also
Push

Field Summary

Modifier and TypeField and Description
private String
private static final long
private Map<String, String>
private WebsocketSessionManager
private WebsocketUserManager
private Map<String, String>

Constructor Summary

AccessConstructor and Description
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 invokes send(Object) during which the session and view scope is not necessarily active anymore.

Method Summary

Modifier and TypeMethod and Description
public Set<Future<Void>>
send(Object
The push message object.
message
)

Implements javax.faces.push.PushContext.send.

Send given message object to the push socket channel as identified by @Push.
public <S extends Serializable> Set<Future<Void>>
send(Object
The push message object.
message
,
S
The user to which the push message object must be delivered to.
user
)

Implements javax.faces.push.PushContext.send.

Send given message object to the push socket channel as identified by @Push, targeted to the given user as identified by <f:websocket user>.
public <S extends Serializable> Map<S, Set<Future<Void>>>
send(Object
The push message object.
message
,
Collection<S>
The users to which the push message object must be delivered to.
users
)

Implements javax.faces.push.PushContext.send, javax.faces.push.PushContext.send.

Send given message object to the push socket channel as identified by @Push, targeted to the given users as identified by <f:websocket user>.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

channelback to summary
private String channel
serialVersionUIDback to summary
private static final long serialVersionUID
sessionScopeback to summary
private Map<String, String> sessionScope
socketSessionsback to summary
private WebsocketSessionManager socketSessions
socketUsersback to summary
private WebsocketUserManager socketUsers
viewScopeback to summary
private Map<String, String> viewScope

Constructor Detail

WebsocketPushContextback to summary
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 invokes send(Object) during which the session and view scope is not necessarily active anymore.

Method Detail

sendback to summary
public Set<Future<Void>> send(Object message)

Implements javax.faces.push.PushContext.send.

Doc from javax.faces.push.PushContext.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 <f:websocket onmessage>.

Parameters
message:Object

The push message object.

Returns:Set<Future<Void>>

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 on Future#get() if the message was successfully delivered and otherwise throw ExecutionException.

Annotations
@Override
sendback to summary
public <S extends Serializable> Set<Future<Void>> send(Object message, S user)

Implements javax.faces.push.PushContext.send.

Doc from javax.faces.push.PushContext.send.

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>.

Parameters
<S>
The generic type of the user identifier.
message:Object

The push message object.

user:S

The user to which the push message object must be delivered to.

Returns:Set<Future<Void>>

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 on Future#get() if the message was successfully delivered and otherwise throw ExecutionException.

Annotations
@Override
sendback to summary
public <S extends Serializable> Map<S, Set<Future<Void>>> send(Object message, Collection<S> users)

Implements javax.faces.push.PushContext.send, javax.faces.push.PushContext.send.

Doc from javax.faces.push.PushContext.send.

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>.

Parameters
<S>
The generic type of the user identifier.
message:Object

The push message object.

users:Collection<S>

The users to which the push message object must be delivered to.

Returns:Map<S, Set<Future<Void>>>

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 on Future#get() if the message was successfully delivered and otherwise throw ExecutionException.

Annotations
@Override