@SessionScoped public class SocketChannelManager extends Object implements Serializable
This web socket channel manager holds all application and session scoped web socket channel identifiers registered by
<o:socket>
.
Socket
,
Serialized FormModifier and Type | Class and Description |
---|---|
protected static class |
SocketChannelManager.ViewScope
This helps the web socket channel manager to hold view scoped web socket channel identifiers registered by
<o:socket> . |
Constructor and Description |
---|
SocketChannelManager() |
Modifier and Type | Method and Description |
---|---|
protected void |
deregisterSessionScope()
When current session scope is about to be destroyed, deregister all session scope channels and explicitly close
any open web sockets associated with it to avoid stale websockets.
|
protected Map<String,String> |
getSessionScopedChannels()
For internal usage only.
|
protected Map<String,String> |
getViewScopedChannels(boolean create)
For internal usage only.
|
protected String |
register(String channel,
String scope,
Serializable user)
Register given channel on given scope and returns the web socket channel identifier.
|
protected void |
switchUser(String channel,
String scope,
Serializable oldUser,
Serializable newUser)
Switch the user on the given channel on the given scope from the given old user to the given new user.
|
protected String register(String channel, String scope, Serializable user)
channel
- The web socket channel.scope
- The web socket scope. Supported values are application
, session
and
view
, case insensitive. If null
, the default is application
.user
- The user object representing the owner of the given channel. If not null
, then scope
may not be application
.IllegalArgumentException
- When the scope is invalid or when channel already exists on a different scope.protected void switchUser(String channel, String scope, Serializable oldUser, Serializable newUser)
channel
- The web socket channel.scope
- The web socket scope. Supported values are application
, session
and
view
, case insensitive. If null
, the default is application
.oldUser
- The user object representing the old owner of the given channel. If not null
, then scope
may not be application
.newUser
- The user object representing the new owner of the given channel. If not null
, then scope
may not be application
.@PreDestroy protected void deregisterSessionScope()
protected Map<String,String> getSessionScopedChannels()
SocketPushContext
(the CDI session scope is not necessarily active during push send time).
This should actually be package private, but package private methods in CDI beans are subject to memory leaks.protected Map<String,String> getViewScopedChannels(boolean create)
SocketPushContext
(the JSF view scope is not necessarily active during push send time).
This should actually be package private, but package private methods in CDI beans are subject to memory leaks.create
- Whether or not to auto-create the entry in JSF view scope.Copyright © 2012–2022 OmniFaces. All rights reserved.