4

I use Quickblox for chat room

My code:

final QBChatDialog dialog = DialogUtils.buildPrivateDialog(id);
dialog.setType(QBDialogType.PRIVATE);

QBRestChatService.createChatDialog(dialog).performAsync(new QBEntityCallback<QBChatDialog>() {
    @Override
    public void onSuccess(QBChatDialog result, Bundle params) {
        try {
            QBChatMessage chatMessage = new QBChatMessage();
            chatMessage.setBody("Hi there!");
            dialog.sendMessage(chatMessage);
        } catch (SmackException.NotConnectedException e) {
            Log.i("errorCheck", "Chat: NO : " + e.getMessage());
        }
    }

    @Override
    public void onError(QBResponseException responseException) {
        Log.i("errorCheck", "Chat: FAIL" + responseException.getMessage());
    }
});

I get this error :

Client is not, or no longer, connected. error

But I'm sure my client is connected

dhilmathy
  • 2,800
  • 2
  • 21
  • 29
Tooti Tooti
  • 109
  • 7

1 Answers1

3

You need to do the following before sending message:

qbChatDialog.initForChat(QBChatService.getInstance());
vijay
  • 324
  • 1
  • 4
  • 11