当前位置: 首页>>代码示例>>Java>>正文


Java DiscussionHistory.setMaxChars方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:FanHuaRan,项目名称:SmackStudy,代码行数:26,代码来源:XMPPUtil.java

示例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;
    }
}
 
开发者ID:FanHuaRan,项目名称:SmackStudy,代码行数:30,代码来源:XMPPUtil.java

示例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);
    }
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:24,代码来源:QuickbloxPrivateXmppConnection.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:64,代码来源:XmppConsumer.java


注:本文中的org.jivesoftware.smackx.muc.DiscussionHistory.setMaxChars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。