in core/src/main/java/flex/messaging/client/FlexClient.java [469:525]
public void invalidate() {
synchronized (lock) {
if (!valid || invalidating)
return; // Already shutting down.
invalidating = true; // This thread gets to shut the FlexClient down.
flexClientManager.removeFlexClient(this);
cancelTimeout();
}
// Unregister from all FlexSessions.
if (!sessions.isEmpty()) {
for (FlexSession session : sessions)
unregisterFlexSession(session);
}
// Invalidate associated MessageClient subscriptions.
if (messageClients != null && !messageClients.isEmpty()) {
for (MessageClient messageClient : messageClients) {
messageClient.removeMessageClientDestroyedListener(this);
messageClient.invalidate();
}
messageClients.clear();
}
// Notify destroy listeners that we're shutting the FlexClient down.
if (destroyedListeners != null && !destroyedListeners.isEmpty()) {
for (FlexClientListener destroyListener : destroyedListeners) {
destroyListener.clientDestroyed(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);
}
// Close any registered push handlers.
if (endpointPushHandlers != null && !endpointPushHandlers.isEmpty()) {
for (EndpointPushHandler handler : endpointPushHandlers.values()) {
handler.close(true /* notify Channel of disconnect */);
}
endpointPushHandlers = null;
}
synchronized (lock) {
valid = false;
invalidating = false;
}
if (Log.isDebug())
Log.getLogger(FLEX_CLIENT_LOG_CATEGORY).debug("FlexClient with id '" + this.id + "' has been invalidated.");
}