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 ofSimpUserRegistrythat relies onAbstractSubProtocolEventapplication context events to keep track of connected users and their subscriptions.- Since:
- 4.2
- Author:
- Rossen Stoyanchev
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor Summary
Constructors Constructor Description DefaultSimpUserRegistry()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<SimpSubscription>findSubscriptions(SimpSubscriptionMatcher matcher)Find subscriptions with the given matcher.intgetOrder()Get the order value of this object.SimpUsergetUser(String userName)Get the user for the given name.intgetUserCount()Return the count of all connected users.Set<SimpUser>getUsers()Return a snapshot of all connected users.voidonApplicationEvent(ApplicationEvent event)Handle an application event.booleansupportsEventType(Class<? extends ApplicationEvent> eventType)Determine whether this listener actually supports the given event type.booleansupportsSourceType(Class<?> sourceType)Determine whether this listener actually supports the given source type.StringtoString()
Constructor Detail
DefaultSimpUserRegistry
public DefaultSimpUserRegistry()
Method Detail
getOrder
public int getOrder()
Description copied from interface:OrderedGet the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startupvalues).Same order values will result in arbitrary sort positions for the affected objects.
- Specified by:
getOrderin interfaceOrdered- Returns:
- the order value
- See Also:
Ordered.HIGHEST_PRECEDENCE,Ordered.LOWEST_PRECEDENCE
supportsEventType
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType)
Description copied from interface:SmartApplicationListenerDetermine whether this listener actually supports the given event type.- Specified by:
supportsEventTypein interfaceSmartApplicationListener- Parameters:
eventType- the event type (nevernull)
onApplicationEvent
public void onApplicationEvent(ApplicationEvent event)
Description copied from interface:ApplicationListenerHandle an application event.- Specified by:
onApplicationEventin interfaceApplicationListener<ApplicationEvent>- Parameters:
event- the event to respond to
supportsSourceType
public boolean supportsSourceType(Class<?> sourceType)
Description copied from interface:SmartApplicationListenerDetermine whether this listener actually supports the given source type.- Specified by:
supportsSourceTypein interfaceSmartApplicationListener- Parameters:
sourceType- the source type, ornullif no source
getUser
public SimpUser getUser(String userName)
Description copied from interface:SimpUserRegistryGet the user for the given name.- Specified by:
getUserin interfaceSimpUserRegistry- Parameters:
userName- the name of the user to look up- Returns:
- the user, or
nullif not connected
getUsers
public Set<SimpUser> getUsers()
Description copied from interface:SimpUserRegistryReturn a snapshot of all connected users.The returned set is a copy and will not reflect further changes.
- Specified by:
getUsersin interfaceSimpUserRegistry- Returns:
- the connected users, or an empty set if none
getUserCount
public int getUserCount()
Description copied from interface:SimpUserRegistryReturn the count of all connected users.- Specified by:
getUserCountin interfaceSimpUserRegistry- Returns:
- the number of connected users
findSubscriptions
public Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher)
Description copied from interface:SimpUserRegistryFind subscriptions with the given matcher.- Specified by:
findSubscriptionsin interfaceSimpUserRegistry- Parameters:
matcher- the matcher to use- Returns:
- a set of matching subscriptions, or an empty set if none