@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也收不到消息。
-
创建时间
16年8月19日
-
最后回复
16年8月19日
-
2
回复
-
875
浏览
-
2
用户