本文整理汇总了Java中org.jivesoftware.smackx.muc.DiscussionHistory.setMaxChars方法的典型用法代码示例。如果您正苦于以下问题:Java DiscussionHistory.setMaxChars方法的具体用法?Java DiscussionHistory.setMaxChars怎么用?Java DiscussionHistory.setMaxChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.muc.DiscussionHistory
的用法示例。
在下文中一共展示了DiscussionHistory.setMaxChars方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: joinMultiUserChat
import org.jivesoftware.smackx.muc.DiscussionHistory; //导入方法依赖的package包/类
/**
* 加入聊天室
* @param xmppConnection
* @param roomName
* @param password
* @return
*/
public static MultiUserChat joinMultiUserChat(XMPPConnection xmppConnection,String roomName,String password,PacketListener packetListener){
try {
// 使用XMPPConnection创建一个MultiUserChat窗口
MultiUserChat muc = new MultiUserChat(xmppConnection, roomName+ "@conference." + xmppConnection.getServiceName());
// 聊天室服务将会决定要接受的历史记录数量
DiscussionHistory history = new DiscussionHistory();
history.setMaxChars(0);
// 用户加入聊天室
muc.join(xmppConnection.getUser(), password, history, SmackConfiguration.getPacketReplyTimeout());
if(packetListener!=null){
muc.addMessageListener(packetListener);
}
return muc;
} catch (XMPPException e) {
e.printStackTrace();
return null;
}
}
示例2: joinMultiUserChat
import org.jivesoftware.smackx.muc.DiscussionHistory; //导入方法依赖的package包/类
/**
* 加入聊天室
* @param xmppConnection
* @param roomName
* @param password
* @param packetListener 消息监听器
* @return
*/
public static MultiUserChat joinMultiUserChat(XMPPConnection xmppConnection,String roomName,String password,PacketListener packetListener){
try {
// 使用XMPPConnection创建一个MultiUserChat窗口
MultiUserChat muc = new MultiUserChat(xmppConnection, roomName+ "@conference." + xmppConnection.getServiceName());
// 聊天室服务将会决定要接受的历史记录数量
DiscussionHistory history = new DiscussionHistory();
history.setMaxChars(0);
// history.setSince(new Date());
// 用户加入聊天室
muc.join(xmppConnection.getUser(), password, history, SmackConfiguration.getPacketReplyTimeout());
Log.i("MultiUserChat", "会议室【"+roomName+"】加入成功........");
if(packetListener!=null){
muc.addMessageListener(packetListener);
}
return muc;
} catch (XMPPException e) {
Log.e("MultiUserChat", "会议室【"+roomName+"】加入失败........");
e.printStackTrace();
return null;
}
}
示例3: joinPublicChat
import org.jivesoftware.smackx.muc.DiscussionHistory; //导入方法依赖的package包/类
public void joinPublicChat(String chatJid, long lastMessageDate) {
try {
MultiUserChat mucChat;
if ((mucChat = publicChats.get(chatJid)) == null) {
mucChat = MultiUserChatManager.getInstanceFor(privateChatConnection).getMultiUserChat(chatJid);
mucChat.addMessageListener(this);
publicChats.put(chatJid, mucChat);
}
DiscussionHistory history = new DiscussionHistory();
if(lastMessageDate != 0)
history.setSince(new Date(lastMessageDate * 1000));
else
history.setMaxChars(0);
mucChat.join(
CurrentUser.getInstance().getCurrentUserId().toString(),
null,
history,
privateChatConnection.getPacketReplyTimeout());
} catch (Exception ex) {
Logger.logExceptionToFabric(ex);
}
}
示例4: doStart
import org.jivesoftware.smackx.muc.DiscussionHistory; //导入方法依赖的package包/类
@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();
history.setMaxChars(0); // we do not want any historical messages
muc.join(endpoint.getNickname(), null, history, SmackConfiguration.getDefaultPacketReplyTimeout());
if (LOG.isInfoEnabled()) {
LOG.info("Joined room: {} as: {}", muc.getRoom(), endpoint.getNickname());
}
}
this.startRobustConnectionMonitor();
super.doStart();
}