org.jivesoftware.smackx.muc.HostedRoom Java Examples

The following examples show how to use org.jivesoftware.smackx.muc.HostedRoom. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmppConnection.java    From weixin with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化会议室列表
 */
public List<HostedRoom> getHostRooms() {
	if (getConnection() == null)
		return null;
	Collection<HostedRoom> hostrooms = null;
	List<HostedRoom> roominfos = new ArrayList<HostedRoom>();
	try {
		new ServiceDiscoveryManager(getConnection());
		hostrooms = MultiUserChat.getHostedRooms(getConnection(), getConnection().getServiceName());
		for (HostedRoom entry : hostrooms) {
			roominfos.add(entry);
			Log.i("room", "名字:" + entry.getName() + " - ID:" + entry.getJid());
		}
		Log.i("room", "服务会议数量:" + roominfos.size());
	} catch (XMPPException e) {
		e.printStackTrace();
	}
	return roominfos;
}
 
Example #2
Source File: XmppManager.java    From weixin with Apache License 2.0 6 votes vote down vote up
/**
 * 获取服务器上所有会议室
 * 
 * @return
 * @throws XMPPException
 */
public List<FriendRooms> getConferenceRoom() throws XMPPException {
	List<FriendRooms> list = new ArrayList<FriendRooms>();
	new ServiceDiscoveryManager(getConnection());
	if (!MultiUserChat.getHostedRooms(getConnection(), getConnection().getServiceName()).isEmpty()) {

		for (HostedRoom k : MultiUserChat.getHostedRooms(getConnection(), getConnection().getServiceName())) {

			for (HostedRoom j : MultiUserChat.getHostedRooms(getConnection(), k.getJid())) {
				RoomInfo info2 = MultiUserChat.getRoomInfo(getConnection(), j.getJid());
				if (j.getJid().indexOf("@") > 0) {

					FriendRooms friendrooms = new FriendRooms();
					friendrooms.setName(j.getName());//聊天室的名称  
					friendrooms.setJid(j.getJid());//聊天室JID  
					friendrooms.setOccupants(info2.getOccupantsCount());//聊天室中占有者数量  
					friendrooms.setDescription(info2.getDescription());//聊天室的描述  
					friendrooms.setSubject(info2.getSubject());//聊天室的主题  
					list.add(friendrooms);
				}
			}
		}
	}
	return list;
}
 
Example #3
Source File: ConferenceRoomBrowser.java    From Spark with Apache License 2.0 5 votes vote down vote up
private void refreshRoomList(final DomainBareJid serviceName) {
    startLoadingImg();
    clearTable();

    TimerTask refreshTask = new TimerTask() {
        Collection<HostedRoom> rooms;

        @Override
        public void run() {
            try {
                rooms = getRoomList(serviceName);
                try { 
                    for (HostedRoom aResult : rooms) {
                        RoomObject room = getRoomsAndInfo(aResult);
                        addRoomToTable(room.getRoomJID(), room.getRoomName(),
                        room.getNumberOfOccupants());
                    }
                    stopLoadingImg();
                } catch (Exception e) {
                    Log.error("Unable to retrieve room list and info.", e);
                }
            } catch ( Exception e1 ) {
                System.err.println(e1);
            }
        }
    };
    TaskEngine.getInstance().submit(refreshTask);
}
 
Example #4
Source File: MultiRoomDiscoverActivity.java    From yiim_v2 with GNU General Public License v2.0 4 votes vote down vote up
private void loadRooms() {
	getXmppBinder().execute(new Runnable() {
		@Override
		public void run() {
			// TODO Auto-generated method stub
			try {
				Collection<HostedRoom> hostedRooms = MultiUserChat
						.getHostedRooms(
								getXmppBinder().getXmppConnection(),
								"conference."
										+ XmppConnectionUtils.getXmppHost());
				if (!hostedRooms.isEmpty()) {
					ArrayList<TabContactsModel> models = new ArrayList<TabContactsModel>();
					for (HostedRoom hostedRoom : hostedRooms) {
						RoomInfo roomInfo = MultiUserChat.getRoomInfo(
								getXmppBinder().getXmppConnection(),
								hostedRoom.getJid());
						TabContactsModel model = new TabContactsModel();

						MultiChatDesc desc = MultiChatDesc
								.fromString(roomInfo.getDescription());

						if (!YiUtils.isStringInvalid(roomInfo.getSubject())) {
							model.setMsg(roomInfo.getSubject());
						} else if (!YiUtils.isStringInvalid(desc.getName())) {
							model.setMsg(desc.getName());
						} else {
							model.setMsg(roomInfo.getRoom());
						}
						model.setUser(roomInfo.getRoom());
						model.setSubMsg(roomInfo.getDescription());
						models.add(model);
					}
					Message message = getHandler().obtainMessage(
							MSG_UPDATE_LIST, models);
					message.sendToTarget();
				}
			} catch (Exception e) {
				// TODO: handle exception
				YiLog.getInstance().e(e, "load rooms failed");
			}
		}
	});
}
 
Example #5
Source File: ConferenceRoomBrowser.java    From Spark with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a Collection of all rooms in the specified Conference Service.
 *
 * @param serviceName
 *            the name of the conference service.
 * @return a Collection of all rooms in the Conference service.
 * @throws Exception
 *             if a problem occurs while getting the room list
 */
private static Collection<HostedRoom> getRoomList(DomainBareJid serviceName)
 throws Exception {
    return MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ).getHostedRooms( serviceName );
}
 
Example #6
Source File: ConferenceUtils.java    From Spark with Apache License 2.0 2 votes vote down vote up
/**
 * Return a list of available Conference rooms from the server
 * based on the service name.
 *
 * @param serviceName the service name (ex. [email protected])
 * @return a collection of rooms.
 * @throws Exception if an error occured during fetch.
 */
public static Collection<HostedRoom> getRoomList(DomainBareJid serviceName) throws Exception {
    return MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ).getHostedRooms( serviceName );
}