use of org.jivesoftware.smackx.muc.DiscussionHistory in project camel by apache.
the class XmppConsumer method doStart.
@Override
protected void doStart() throws Exception {
try {
connection = endpoint.createConnection();
} catch (SmackException e) {
if (endpoint.isTestConnectionOnStartup()) {
throw new RuntimeException("Could not connect to XMPP server.", e);
} else {
LOG.warn(e.getMessage());
if (getExceptionHandler() != null) {
getExceptionHandler().handleException(e.getMessage(), e);
}
scheduleDelayedStart();
return;
}
}
chatManager = ChatManager.getInstanceFor(connection);
chatManager.addChatListener(this);
OrFilter pubsubPacketFilter = new OrFilter();
if (endpoint.isPubsub()) {
//xep-0060: pubsub#notification_type can be 'headline' or 'normal'
pubsubPacketFilter.addFilter(new MessageTypeFilter(Type.headline));
pubsubPacketFilter.addFilter(new MessageTypeFilter(Type.normal));
connection.addPacketListener(this, pubsubPacketFilter);
}
if (endpoint.getRoom() == null) {
privateChat = chatManager.getThreadChat(endpoint.getChatId());
if (privateChat != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Adding listener to existing chat opened to " + privateChat.getParticipant());
}
privateChat.addMessageListener(this);
} else {
privateChat = ChatManager.getInstanceFor(connection).createChat(endpoint.getParticipant(), endpoint.getChatId(), this);
if (LOG.isDebugEnabled()) {
LOG.debug("Opening private chat to " + privateChat.getParticipant());
}
}
} else {
// add the presence packet listener to the connection so we only get packets that concerns us
// we must add the listener before creating the muc
final AndFilter packetFilter = new AndFilter(new PacketTypeFilter(Presence.class));
connection.addPacketListener(this, packetFilter);
muc = new MultiUserChat(connection, endpoint.resolveRoom(connection));
muc.addMessageListener(this);
DiscussionHistory history = new DiscussionHistory();
// we do not want any historical messages
history.setMaxChars(0);
muc.join(endpoint.getNickname(), null, history, SmackConfiguration.getDefaultPacketReplyTimeout());
if (LOG.isInfoEnabled()) {
LOG.info("Joined room: {} as: {}", muc.getRoom(), endpoint.getNickname());
}
}
this.startRobustConnectionMonitor();
super.doStart();
}
use of org.jivesoftware.smackx.muc.DiscussionHistory in project camel by apache.
the class XmppGroupChatProducer method initializeChat.
protected synchronized void initializeChat() throws XMPPException, SmackException {
if (chat == null) {
room = endpoint.resolveRoom(connection);
chat = new MultiUserChat(connection, room);
DiscussionHistory history = new DiscussionHistory();
// we do not want any historical messages
history.setMaxChars(0);
chat.join(endpoint.getNickname(), null, history, SmackConfiguration.getDefaultPacketReplyTimeout());
if (LOG.isInfoEnabled()) {
LOG.info("Joined room: {} as: {}", room, endpoint.getNickname());
}
}
}
Aggregations