Here's what I ended up using to make things work:
1. I created a class of my own called ExtendedSimpleChat,
which extends SimpleChat
2. I added an "unsubscribe" method (shown below) to this
class, which disconnects and destroys the existing model and
userManager instances in the SimpleChat class (and clears the
history and message input UI objects)
3. To switch rooms, I call the following methods (cSession is
the ConnectSessionContainer instance)
chatPod.unsubscribe();
cSession.logout();
cSession.roomURL = "new URL goes here";
cSession.login();
4. In the event handler for
SessionEvent.SYNCHRONIZATION_CHANGE, if the session is
synchronized, I call:
chatPod.subscribe();
This combination seems to work well. It would probably be a
good idea to add this unsubscribe method to the SimpleChat class.
The "close()" method in SimpleChat disconnects too many other
things.
-------------------------------------------------------------------------------------
public function unsubscribe() : void {
if (_model) {
_model.close();
_model.removeEventListener(CollectionNodeEvent.SYNCHRONIZATION_CHANGE,
onSynchronizationChange);
_model.removeEventListener(ChatEvent.HISTORY_CHANGE,
onHistoryChange);
_model.removeEventListener(ChatEvent.TYPING_LIST_UPDATE,
onTypingListUpdate);
_model.removeEventListener(ChatEvent.ALLOW_PRIVATE_CHAT_CHANGE,
onAllowPrivateChange);
_model = null;
}
if(_userManager) {
_userManager.removeEventListener(UserEvent.USER_CREATE,
dirtyUserList);
_userManager.removeEventListener(UserEvent.USER_REMOVE,
onUserRemove);
_userManager.removeEventListener(UserEvent.USER_ROLE_CHANGE,
onUserRoleChange);
_userManager = null;
}
_history.htmlText = "" ;
_newMessage.text = "" ;
}