public class DefaultSimpUserRegistry extends java.lang.Object implements SimpUserRegistry, SmartApplicationListener
SimpUserRegistry
that relies on
AbstractSubProtocolEvent
application context events to keep
track of connected users and their subscriptions.HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
DefaultSimpUserRegistry() |
Modifier and Type | Method and Description |
---|---|
java.util.Set<SimpSubscription> |
findSubscriptions(SimpSubscriptionMatcher matcher)
Find subscriptions with the given matcher.
|
int |
getOrder()
Determine this listener's order in a set of listeners for the same event.
|
SimpUser |
getUser(java.lang.String userName)
Get the user for the given name.
|
int |
getUserCount()
Return the count of all connected users.
|
java.util.Set<SimpUser> |
getUsers()
Return a snapshot of all connected users.
|
void |
onApplicationEvent(ApplicationEvent event)
Handle an application event.
|
void |
setOrder(int order)
Specify the order value for this registry.
|
boolean |
supportsEventType(java.lang.Class<? extends ApplicationEvent> eventType)
Determine whether this listener actually supports the given event type.
|
boolean |
supportsSourceType(java.lang.Class<?> sourceType)
Determine whether this listener actually supports the given source type.
|
java.lang.String |
toString() |
public void setOrder(int order)
Default is Ordered.LOWEST_PRECEDENCE
.
public int getOrder()
SmartApplicationListener
The default implementation returns Ordered.LOWEST_PRECEDENCE
.
getOrder
in interface SmartApplicationListener
getOrder
in interface Ordered
Ordered.HIGHEST_PRECEDENCE
,
Ordered.LOWEST_PRECEDENCE
public boolean supportsEventType(java.lang.Class<? extends ApplicationEvent> eventType)
SmartApplicationListener
supportsEventType
in interface SmartApplicationListener
eventType
- the event type (never null
)public void onApplicationEvent(ApplicationEvent event)
ApplicationListener
onApplicationEvent
in interface ApplicationListener<ApplicationEvent>
event
- the event to respond topublic boolean supportsSourceType(@Nullable java.lang.Class<?> sourceType)
SmartApplicationListener
The default implementation always returns true
.
supportsSourceType
in interface SmartApplicationListener
sourceType
- the source type, or null
if no source@Nullable public SimpUser getUser(java.lang.String userName)
SimpUserRegistry
getUser
in interface SimpUserRegistry
userName
- the name of the user to look upnull
if not connectedpublic java.util.Set<SimpUser> getUsers()
SimpUserRegistry
The returned set is a copy and will not reflect further changes.
getUsers
in interface SimpUserRegistry
public int getUserCount()
SimpUserRegistry
getUserCount
in interface SimpUserRegistry
public java.util.Set<SimpSubscription> findSubscriptions(SimpSubscriptionMatcher matcher)
SimpUserRegistry
findSubscriptions
in interface SimpUserRegistry
matcher
- the matcher to usepublic java.lang.String toString()
toString
in class java.lang.Object