Class DefaultSimpUserRegistry
java.lang.Object
org.springframework.web.socket.messaging.DefaultSimpUserRegistry
- All Implemented Interfaces:
EventListener
,ApplicationListener<ApplicationEvent>
,SmartApplicationListener
,Ordered
,SimpUserRegistry
public class DefaultSimpUserRegistry
extends Object
implements SimpUserRegistry, SmartApplicationListener
A default implementation of
SimpUserRegistry
that relies on
AbstractSubProtocolEvent
application context events to keep
track of connected users and their subscriptions.- Since:
- 4.2
- Author:
- Rossen Stoyanchev, Sam Brannen
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfindSubscriptions
(SimpSubscriptionMatcher matcher) Find subscriptions with the given matcher.int
getOrder()
Determine this listener's order in a set of listeners for the same event.Get the user for the given name.int
Return the count of all connected users.getUsers()
Return a snapshot of all connected users.void
Handle an application event.void
setOrder
(int order) Specify the order value for this registry.boolean
supportsEventType
(Class<? extends ApplicationEvent> eventType) Determine whether this listener actually supports the given event type.boolean
supportsSourceType
(Class<?> sourceType) Determine whether this listener actually supports the given source type.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.context.event.SmartApplicationListener
getListenerId
-
Constructor Details
-
DefaultSimpUserRegistry
public DefaultSimpUserRegistry()
-
-
Method Details
-
setOrder
public void setOrder(int order) Specify the order value for this registry.Default is
Ordered.LOWEST_PRECEDENCE
.- Since:
- 5.0.8
-
getOrder
public int getOrder()Description copied from interface:SmartApplicationListener
Determine this listener's order in a set of listeners for the same event.The default implementation returns
Ordered.LOWEST_PRECEDENCE
.- Specified by:
getOrder
in interfaceOrdered
- Specified by:
getOrder
in interfaceSmartApplicationListener
- Returns:
- the order value
- See Also:
-
supportsEventType
Description copied from interface:SmartApplicationListener
Determine whether this listener actually supports the given event type.- Specified by:
supportsEventType
in interfaceSmartApplicationListener
- Parameters:
eventType
- the event type (nevernull
)
-
onApplicationEvent
Description copied from interface:ApplicationListener
Handle an application event.- Specified by:
onApplicationEvent
in interfaceApplicationListener<ApplicationEvent>
- Parameters:
event
- the event to respond to
-
supportsSourceType
Description copied from interface:SmartApplicationListener
Determine whether this listener actually supports the given source type.The default implementation always returns
true
.- Specified by:
supportsSourceType
in interfaceSmartApplicationListener
- Parameters:
sourceType
- the source type, ornull
if no source
-
getUser
Description copied from interface:SimpUserRegistry
Get the user for the given name.- Specified by:
getUser
in interfaceSimpUserRegistry
- Parameters:
userName
- the name of the user to look up- Returns:
- the user, or
null
if not connected
-
getUsers
Description copied from interface:SimpUserRegistry
Return a snapshot of all connected users.The returned set is a copy and will not reflect further changes.
- Specified by:
getUsers
in interfaceSimpUserRegistry
- Returns:
- the connected users, or an empty set if none
-
getUserCount
public int getUserCount()Description copied from interface:SimpUserRegistry
Return the count of all connected users.- Specified by:
getUserCount
in interfaceSimpUserRegistry
- Returns:
- the number of connected users
-
findSubscriptions
Description copied from interface:SimpUserRegistry
Find subscriptions with the given matcher.- Specified by:
findSubscriptions
in interfaceSimpUserRegistry
- Parameters:
matcher
- the matcher to use- Returns:
- a set of matching subscriptions, or an empty set if none
-
toString
-