this.connection.addPacketListener(listener, filter);
}
private MultiUserChat getOrCreateGroupChat(GroupChatIMMessageTarget chat) throws IMException {
WeakReference<MultiUserChat> ref = groupChatCache.get(chat.getName());
MultiUserChat groupChat = null;
if (ref != null) {
groupChat = ref.get();
}
if (groupChat == null) {
groupChat = new MultiUserChat(this.connection, chat.getName());
try {
groupChat.join(this.groupChatNick, chat.getPassword());
} catch (XMPPException e) {
LOGGER.warning("Cannot join group chat '" + chat + "'. Exception:\n" + ExceptionHelper.dump(e));
throw new IMException(e);
} catch (SmackException e) {
LOGGER.warning("Cannot join group chat '" + chat + "'. Exception:\n" + ExceptionHelper.dump(e));
throw new IMException(e);
}
// get rid of old messages:
while (groupChat.pollMessage() != null) {
}
this.bots.add(new Bot(new JabberMultiUserChat(groupChat, this, !chat.isNotificationOnly()),
this.groupChatNick, this.desc.getHost(),
this.botCommandPrefix, this.authentication));