in core/src/main/java/flex/messaging/FlexSession.java [618:679]
public void invalidate() {
synchronized (lock) {
if (!valid || invalidating)
return; // Already shutting down.
invalidating = true; // This thread gets to shut the FlexSession down.
cancelTimeout();
if (sessionProvider != null)
sessionProvider.removeFlexSession(this);
}
// Unregister all FlexClients.
if (!flexClients.isEmpty()) {
for (FlexClient flexClient : flexClients)
unregisterFlexClient(flexClient);
}
// Invalidate associated MessageClient subscriptions.
if (messageClients != null && !messageClients.isEmpty()) {
for (Iterator<MessageClient> iter = messageClients.iterator(); iter.hasNext(); ) {
MessageClient messageClient = iter.next();
messageClient.removeMessageClientDestroyedListener(this);
messageClient.invalidate();
}
messageClients.clear();
}
// Notify destroy listeners that we're shutting the FlexSession down.
if (destroyedListeners != null && !destroyedListeners.isEmpty()) {
for (FlexSessionListener destroyListener : destroyedListeners) {
destroyListener.sessionDestroyed(this);
}
destroyedListeners.clear();
}
// Unbind all attributes.
if (attributes != null && !attributes.isEmpty()) {
Set<String> keySet = attributes.keySet();
String[] keys = keySet.toArray(new String[keySet.size()]);
for (String key : keys)
removeAttribute(key);
attributes = null;
}
internalInvalidate();
synchronized (lock) {
valid = false;
invalidating = false;
}
// Notify any waiting threads.
if (waitMonitor != null) {
for (FlexClient.EndpointQueue endpointQueue : waitMonitor.values()) {
synchronized (endpointQueue) {
endpointQueue.notifyAll();
}
}
}
}