java.lang.Object
org.omnifaces.cdi.push.SseSessionManager
This SSE session manager holds all SSE connections by their channel identifier.
- Since:
- 5.2
- Author:
- Bauke Scholtz
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanadd(String channelId, String channel, AsyncContext asyncContext) On open, add given async context to the mapping associated with given channel identifier and returntrueif it's accepted (i.e. the channel identifier is known), otherwisefalse.protected booleanaddSession(String channelId, AsyncContext session) Add a session to the collection associated with the given channel identifier.protected voidcloseSession(AsyncContext asyncContext) Close the given session.protected voidderegister(Iterable<String> channelIds) Deregister given channel identifiers and explicitly close all open sessions associated with them.protected booleanisOpen(AsyncContext session) Returns 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(String channelId, AsyncContext asyncContext) Remove given async context from the mapping associated with given channel identifier.protected booleanremoveSession(String channelId, AsyncContext 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(AsyncContext asyncContext, String message) Send the given message to the given session.
-
Constructor Details
-
SseSessionManager
public SseSessionManager()
-
-
Method Details
-
add
On open, add given async context to the mapping associated with given channel identifier and returntrueif it's accepted (i.e. the channel identifier is known), otherwisefalse.- Parameters:
channelId- The channel identifier.channel- The channel name.asyncContext- The opened async context.- Returns:
trueif given async context is accepted, otherwisefalse.
-
remove
Remove given async context from the mapping associated with given channel identifier.- Parameters:
channelId- The channel identifier.asyncContext- The async context to remove.
-
sendToSession
Send the given message to the given session.- Parameters:
asyncContext- The transport session.message- The push message string.- Returns:
- The result of the send operation, or
nullif the session is no longer usable.
-
closeSession
Close the given session.- Parameters:
asyncContext- 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.
-
isOpen
Returns whether the given session is still open.- Parameters:
session- The transport session.- Returns:
trueif the session is open.
-
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.
-