コード例 #1
0
 public void joinRoomChat(QBDialog dialog)
     throws XMPPException, SmackException, QBResponseException {
   QBGroupChat roomChat = createChatIfNotExist(dialog);
   if (!roomChat.isJoined()) {
     DiscussionHistory history = new DiscussionHistory();
     history.setMaxStanzas(0);
     roomChat.join(history);
   }
 }
コード例 #2
0
 public void leaveDialogs() throws XMPPException, SmackException.NotConnectedException {
   if (groupDialogsList != null) {
     for (QBDialog dialog : groupDialogsList) {
       QBGroupChat roomChat = groupChatManager.getGroupChat(dialog.getRoomJid());
       if (roomChat != null && roomChat.isJoined()) {
         roomChat.leave();
       }
     }
   }
 }
コード例 #3
0
 private void sendRoomMessage(QBChatMessage chatMessage, String roomJId, String dialogId)
     throws QBResponseException {
   groupChat = groupChatManager.getGroupChat(roomJId);
   QBDialog existingDialog = null;
   if (groupChat == null) {
     existingDialog = ChatUtils.getExistDialogById(context, dialogId);
     groupChat = (QBGroupChat) createChatLocally(existingDialog, null);
   }
   String error = null;
   if (!TextUtils.isEmpty(dialogId)) {
     chatMessage.setProperty(ChatUtils.PROPERTY_DIALOG_ID, dialogId);
   }
   try {
     groupChat.sendMessage(chatMessage);
   } catch (XMPPException e) {
     error = context.getString(R.string.dlg_fail_send_msg);
   } catch (SmackException.NotConnectedException e) {
     error = context.getString(R.string.dlg_fail_connection);
   } catch (IllegalStateException e) {
     ErrorUtils.showError(context, context.getString(R.string.dlg_not_joined_room));
     tryJoinRoomChat(existingDialog);
   }
   if (error != null) {
     throw new QBResponseException(error);
   }
 }
コード例 #4
0
 private QBGroupChat createChatIfNotExist(QBDialog dialog) throws QBResponseException {
   boolean notNull = Utils.validateNotNull(groupChatManager);
   if (!notNull) {
     ErrorUtils.logError(TAG, " groupChatManager is NULL");
     throw new QBResponseException(context.getString(R.string.dlg_fail_create_chat));
   }
   groupChat = groupChatManager.getGroupChat(dialog.getRoomJid());
   if (groupChat == null) {
     groupChat = groupChatManager.createGroupChat(dialog.getRoomJid());
     groupChat.addMessageListener(roomChatMessageListener);
   }
   return groupChat;
 }