Package org.apache.myfaces.push.cdi
Class WebsocketViewBean
- java.lang.Object
-
- org.apache.myfaces.push.cdi.WebsocketViewBean
-
- All Implemented Interfaces:
Serializable
@ViewScoped public class WebsocketViewBean extends Object implements Serializable
The purpose of this view scope bean is keep track of the channelTokens used in this view and if the view is discarded, destroy the websocket sessions associated with the view because they are no longer valid.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description WebsocketViewBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
String
getChannelToken(WebsocketChannelMetadata metadata)
List<String>
getChannelTokensFor(String channel)
<S extends Serializable>
List<String>getChannelTokensFor(String channel, S user)
boolean
isChannelAvailable(String channel)
Indicate if the channel mentioned is valid for view scope.void
registerToken(String token, WebsocketChannelMetadata metadata)
void
registerWebsocketSession(String token, WebsocketChannelMetadata metadata)
-
-
-
Method Detail
-
registerToken
public void registerToken(String token, WebsocketChannelMetadata metadata)
-
registerWebsocketSession
public void registerWebsocketSession(String token, WebsocketChannelMetadata metadata)
-
isChannelAvailable
public boolean isChannelAvailable(String channel)
Indicate if the channel mentioned is valid for view scope. A channel is valid if there is at least one token that represents a valid connection to this channel.- Parameters:
channel
-- Returns:
-
getChannelToken
public String getChannelToken(WebsocketChannelMetadata metadata)
-
getChannelTokensFor
public <S extends Serializable> List<String> getChannelTokensFor(String channel, S user)
-
destroy
@PreDestroy public void destroy()
-
-