public void connect(ID remote, IConnectContext connectContext) throws ContainerConnectException {
if (!(remote instanceof XMPPRoomID)) {
throw new ContainerConnectException(NLS.bind(Messages.XMPPChatRoomContainer_Exception_Connect_Wrong_Type, remote));
}
final XMPPRoomID roomID = (XMPPRoomID) remote;
fireContainerEvent(new ContainerConnectingEvent(this.getID(), remote, connectContext));
synchronized (getConnectLock()) {
try {
connectionState = CONNECTING;
remoteServerID = null;
addSharedObjectToContainer(remote);
multiuserchat = new MultiUserChat(getXMPPConnection(), roomID.getMucString());
// Get nickname from join context
String nick = null;
try {
final Callback[] callbacks = new Callback[1];
callbacks[0] = new NameCallback(Messages.XMPPChatRoomContainer_NAME_CALLBACK_NICK, roomID.getNickname());
if (connectContext != null) {
final CallbackHandler handler = connectContext.getCallbackHandler();
if (handler != null) {
handler.handle(callbacks);
}
}
if (callbacks[0] instanceof NameCallback) {
final NameCallback cb = (NameCallback) callbacks[0];
nick = cb.getName();
}
} catch (final Exception e) {
throw new ContainerConnectException(Messages.XMPPChatRoomContainer_EXCEPTION_CALLBACKHANDLER, e);
}
String nickname = null;
if (nick == null || nick.equals("")) //$NON-NLS-1$
nickname = roomID.getNickname();
else
nickname = nick;
multiuserchat.addSubjectUpdatedListener(new SubjectUpdatedListener() {
public void subjectUpdated(String subject, String from) {
fireSubjectUpdated(subject, from);