Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

客户端订阅主题后,mqtt会自动发送消息给客户端 #30

Closed
itkun2013 opened this issue Jun 19, 2017 · 2 comments
Closed

客户端订阅主题后,mqtt会自动发送消息给客户端 #30

itkun2013 opened this issue Jun 19, 2017 · 2 comments

Comments

@itkun2013
Copy link

项目涉及及时通讯,需要创建一个消息群,类似qq群,目前遇到一个问题:
当我客户端ClientA订阅群组GroupidC, subscribe(new String[]{bean.getMsgContent()}, new int[]{2});群组成员正常聊天,当ClientA退出群聊,已经把本地的聊天信息删除了,取消订阅该群unsubscribe(new` String[]{groupId});。然后群组重新添加ClientA,过一会儿,ClientA会自动加载删除前的聊天信息,想问下,mqtt是否有保留历史消息机制,需要怎么做才不会加载历史消息
下面附下我的部分代码:
订阅方面:
// 创建MQTT链接
super.connect(this.clientId, CLEAN_START, CONN_TIMEOUT);
// 订阅主题,主题和消息质量(为2,长连接)
super.subscribe(this.topics, qosValue);
解绑订阅:
MqttService.mqttClient.unsubscribe(new String[]{groupId});

@mcxiaoke
Copy link
Owner

与客户端和服务端的实现都有关系,看一下 0301-CONNECT Clean Session 部分

@itkun2013
Copy link
Author

能否确切点,大神,是客户端问题还是服务端问题

@mcxiaoke mcxiaoke closed this as completed Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants