@Override
  public void onMessage(AVIMTypedMessage message, AVIMConversation conversation, AVIMClient client) {
    LogUtil.log.d("message = " + message + " conversation = " + conversation + " client = " + client);
    String clientID = "";
    try {
      clientID = AVImClientManager.getInstance().getClientId();
      LogUtil.log.i("clientId = " + clientID + " == " + client.getClientId());
      if (client.getClientId().equals(clientID)) {

        // 过滤掉自己发的消息
        if (!message.getFrom().equals(clientID)) {
          sendEvent(message, conversation);
          if (NotificationUtils.isShowNotification(conversation.getConversationId())) {
            sendNotification(message, conversation);
          }
        }
      } else {
        LogUtil.log.e("----client close---");
        client.close(null);
      }
    } catch (IllegalStateException e) {
      LogUtil.log.e("----client close exception---");
      e.printStackTrace();
      client.close(null);
    }
  }

上面是官方demo:leanmessage-demo MessageHandler 的代码,当切换client后,前面的client调用close,会导致当前的client也收不到消息。

你好,第二个 clientId 登录时,需要再次调用 open()。

你好,我具体操作是这样的:
a用户登陆进入到对话界面,然后双击退出,再b用户登录,这时其实是a,b两个client都是在open状态,这时收到一条消息,上面的的 onMessage 函数会回调两次,其中一次a client调用close,但会导致b也收不到消息(是否是整个应用都close了呢?),这时b必须重新登录调用open

不知道这样是不是你的预期,如果是的话那感觉demo这样写逻辑有点问题吧,而且我看chatkit也是这样写的