java.lang.Object
org.omnifaces.cdi.push.SocketSessionManager
This web socket session manager holds all web socket sessions by their channel identifier.
- Since:
- 2.3
- Author:
- Bauke Scholtz
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanOn open, add given web socket session to the mapping associated with its channel identifier and returnstrueif it's accepted (i.e. the channel identifier is known) and the same session hasn't been added before, otherwisefalse.protected booleanaddSession(String channelId, Session session) Add a session to the collection associated with the given channel identifier.protected voidcloseSession(Session session) Close the given session.protected voidderegister(Iterable<String> channelIds) Deregister given channel identifiers and explicitly close all open sessions associated with them.protected booleanReturns whether the given session is still open.protected booleanisRegistered(String channelId) Returns whether the given channel identifier is registered.protected voidRegister given channel identifiers.protected voidRegister given channel identifier.protected voidremove(Session session, CloseReason reason) On close, remove given web socket session from the mapping.protected booleanremoveSession(String channelId, Session session) Remove a session from the collection associated with the given channel identifier.Send the given message to all open sessions associated with given channel identifier.sendToSession(Session session, String message) Send the given message to the given session.
-
Constructor Details
-
SocketSessionManager
public SocketSessionManager()
-
-
Method Details
-
add
On open, add given web socket session to the mapping associated with its channel identifier and returnstrueif it's accepted (i.e. the channel identifier is known) and the same session hasn't been added before, otherwisefalse.- Parameters:
session- The opened web socket session.- Returns:
trueif given web socket session is accepted and is new, otherwisefalse.
-
remove
On close, remove given web socket session from the mapping.- Parameters:
session- The closed web socket session.reason- The close reason.
-
sendToSession
Send the given message to the given session.- Parameters:
session- The transport session.message- The push message string.- Returns:
- The result of the send operation, or
nullif the session is no longer usable.
-
isOpen
Returns whether the given session is still open.- Parameters:
session- The transport session.- Returns:
trueif the session is open.
-
closeSession
Close the given session.- Parameters:
session- The transport session to close.
-
register
Register given channel identifier.- Parameters:
channelId- The channel identifier to register.
-
register
Register given channel identifiers.- Parameters:
channelIds- The channel identifiers to register.
-
send
Send the given message to all open sessions associated with given channel identifier.- Parameters:
channelId- The channel identifier.message- The push message string.- Returns:
- The results of the send operation. If it returns an empty set, then there was no open session associated
with given channel identifier. The returned futures will return
nullonFuture.get()if the message was successfully delivered and otherwise throwExecutionException.
-
deregister
Deregister given channel identifiers and explicitly close all open sessions associated with them.- Parameters:
channelIds- The channel identifiers to deregister.
-
isRegistered
Returns whether the given channel identifier is registered.- Parameters:
channelId- The channel identifier.- Returns:
trueif the channel identifier is registered, otherwisefalse.
-
addSession
Add a session to the collection associated with the given channel identifier.- Parameters:
channelId- The channel identifier.session- The transport session to add.- Returns:
trueif the channel identifier is known and the session was added, otherwisefalse.
-
removeSession
Remove a session from the collection associated with the given channel identifier.- Parameters:
channelId- The channel identifier.session- The transport session to remove.- Returns:
trueif the session was present and removed, otherwisefalse.
-