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


Java DiscussionHistory.setMaxStanzas方法代码示例

本文整理汇总了Java中org.jivesoftware.smackx.muc.DiscussionHistory.setMaxStanzas方法的典型用法代码示例。如果您正苦于以下问题:Java DiscussionHistory.setMaxStanzas方法的具体用法?Java DiscussionHistory.setMaxStanzas怎么用?Java DiscussionHistory.setMaxStanzas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smackx.muc.DiscussionHistory的用法示例。


在下文中一共展示了DiscussionHistory.setMaxStanzas方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: start

import org.jivesoftware.smackx.muc.DiscussionHistory; //导入方法依赖的package包/类
public void start(ITetradCallback callback) {
    logger.debug("start");
    logger.info(MessageFormat.format("Connecting to service {0} with username {1} and resource {2}",
                                     service_domain,
                                     username,
                                     resource
                                    ));
    this.callback = callback;
    try {
        XMPPConnection xmppConnection = new XMPPConnection(service_domain);
        xmppConnection.connect();

        xmppConnection.login(username, password, resource);

        DiscussionHistory history = new DiscussionHistory();
        history.setMaxStanzas(0);

        for (String room : rooms) {
            final String roomJID = room + "@" + getChatService();
            logger.info(MessageFormat.format("Connecting to room {0}", roomJID));
            MultiUserChat chat = new MultiUserChat(xmppConnection, roomJID);
            chat.join(xmppConnection.getUser(), password, history, SmackConfiguration.getPacketReplyTimeout());
            chat.addMessageListener(packet -> this.handleMessage((Message) packet, roomJID));
            chat.changeNickname("β");
            connectedRooms.put(room, chat);
        }
    } catch (XMPPException e) {
        logger.error(MessageFormat.format("Error connecting to service {0} with username {1} and resource {2}. Message: {3}",
                                          service_domain,
                                          username,
                                          resource,
                                          e.getMessage()
                                         ));
    }
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:36,代码来源:TetradXMPP.java

示例2: joinRoom

import org.jivesoftware.smackx.muc.DiscussionHistory; //导入方法依赖的package包/类
/**
 * ����������
 * 
 * @param user
 * @param pwd
 *            ����������
 * @param roomName
 * @return
 */
public MultiUserChat joinRoom(String user, String pwd, String roomName) {
	MultiUserChat muc = new MultiUserChat(connection,
			roomName.contains(CONFERENCE) ? roomName : roomName
					+ CONFERENCE + connection.getServiceName());
	DiscussionHistory history = new DiscussionHistory();
	history.setMaxStanzas(100);
	history.setSince(new Date(2014, 07, 31));
	// history.setSince(new Date());
	try {
		muc.join(user, pwd, history,
				SmackConfiguration.getPacketReplyTimeout());
		Message msg = muc.nextMessage();
		if (null != msg)
			SLog.i(tag, msg.toXML());

		Message msg2 = muc.nextMessage(100);
		if (null != msg2)
			SLog.i(tag, msg2.toXML());

	} catch (XMPPException e) {
		SLog.e(tag, " ���� ������ ����");
		SLog.e(tag, Log.getStackTraceString(e));
		return null;
	}
	return muc;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:36,代码来源:XmppConnectionManager.java

示例3: joinMultiUserChat

import org.jivesoftware.smackx.muc.DiscussionHistory; //导入方法依赖的package包/类
/**
 * 加入会议室
 * 
 * @param user
 *            昵称
 * @param password
 *            会议室密码
 * @param roomsName
 *            会议室名
 */
public static MultiUserChat joinMultiUserChat(Context context, String user,
		String roomJid, String password) throws Exception {
	XMPPConnection connection = XmppConnectionUtils.getInstance()
			.getRawConnection();
	if (connection == null || !connection.isConnected()
			|| !connection.isAuthenticated())
		throw new Exception("connection not ready");

	Cursor cursor = null;
	try {
		// 使用XMPPConnection创建一个MultiUserChat窗口
		MultiUserChat muc = new MultiUserChat(connection, roomJid);
		// 聊天室服务将会决定要接受的历史记录数量
		DiscussionHistory history = new DiscussionHistory();

		cursor = context.getContentResolver().query(
				MultiChatRoomColumns.CONTENT_URI,
				new String[] { MultiChatRoomColumns.LAST_MSG_TIME },
				MultiChatRoomColumns.ROOM_JID + "='" + roomJid + "' and "
						+ MultiChatRoomColumns.OWNER + "='"
						+ UserInfo.getUserInfo(context).getUser() + "'",
				null, null);
		if (cursor != null && cursor.getCount() == 1) {
			cursor.moveToFirst();
			history.setSince(new Date(cursor.getLong(0)));
		} else {
			history.setMaxStanzas(15);
		}
		// 用户加入聊天室
		muc.join(StringUtils.escapeUserHost(user), password, history,
				SmackConfiguration.getPacketReplyTimeout());
		return muc;
	} catch (Exception e) {
		throw e;
	} finally {
		if (cursor != null) {
			cursor.close();
			cursor = null;
		}
	}
}
 
开发者ID:ikantech,项目名称:yiim_v2,代码行数:52,代码来源:YiIMUtils.java


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