コード例 #1
0
  /**
   * 获取服务器上所有会议室
   *
   * @return
   * @throws org.jivesoftware.smack.XMPPException
   */
  public static List<FriendRooms> getConferenceRoom(ImConnection talkConnection)
      throws XMPPException {
    if (talkConnection == null) return null;
    XMPPConnection connection = talkConnection.getXMPPConnection();
    if (connection == null) return null;
    List<FriendRooms> list = new ArrayList<FriendRooms>();
    new ServiceDiscoveryManager(connection);
    if (!MultiUserChat.getHostedRooms(connection, connection.getServiceName()).isEmpty()) {
      for (HostedRoom k : MultiUserChat.getHostedRooms(connection, connection.getServiceName())) {

        for (HostedRoom j : MultiUserChat.getHostedRooms(connection, k.getJid())) {
          RoomInfo info2 = MultiUserChat.getRoomInfo(connection, 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;
  }
コード例 #2
0
 /**
  * Returns the RoomInfo if the room exits Allows an simple check for existence of a room
  *
  * @param room
  * @return the roomInfo or null
  */
 private RoomInfo getRoomInfo(String room) {
   RoomInfo info;
   try {
     info = MultiUserChat.getRoomInfo(mConnection, room);
   } catch (Exception e) {
     return null;
   }
   return info;
 }