mirror of
https://github.com/WuKongIM/WuKongIMAndroidSDK
synced 2025-06-06 09:08:33 +00:00
修改聊天消息同步时存在不连续时未同步接口问题
This commit is contained in:
parent
47ea031673
commit
75d9dc8173
Binary file not shown.
@ -1 +1 @@
|
|||||||
3f93544eb1654acb3a4fb20f20a2e60e
|
6be2d9ec1b26667d621f57e2a291a074
|
@ -1 +1 @@
|
|||||||
dc3a097ac17b4302a211adcf10768c4a4ff9bf7b
|
a17ded59f323c4f09095f4203cbf7dcc07025da5
|
@ -1 +1 @@
|
|||||||
22a85d8c1b276d428decdff1878bda476e11550fed96879221aef5998bba130a
|
5ea5cc3a46e2a3af3a2c2aa6868da5d8deddff4eb50bf2fe776d2ff7a28430bd
|
@ -1 +1 @@
|
|||||||
571205bfba040264aac10c072ec7feb133445abd67b7da4e9f1f51d2efb7ee233a2cf400ce6e511205bc1b81b744ffdae99eb5d8345aabe4818885f04aa5fc7e
|
81f68231418225581b0a4a5f8c9b9d97b4c99bc57d567fb2a1275b0884d9fbaa0b3d223ab6b64b3f6b450c484dcd46f0ed52966db28252fe193f86a760496054
|
@ -8,6 +8,6 @@
|
|||||||
<versions>
|
<versions>
|
||||||
<version>1.0.1</version>
|
<version>1.0.1</version>
|
||||||
</versions>
|
</versions>
|
||||||
<lastUpdated>20230719144158</lastUpdated>
|
<lastUpdated>20230720075529</lastUpdated>
|
||||||
</versioning>
|
</versioning>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
@ -1 +1 @@
|
|||||||
919470fe90766da4792e54f44e1a9c9e
|
65f3905d05116a1ba2776ba0b236742e
|
@ -1 +1 @@
|
|||||||
5bac2f6f086268d971dbacc7acc8e630cc36c782
|
8d0196ef615d28b8806e3300083cd40f5e3306cb
|
@ -1 +1 @@
|
|||||||
b9ce184c288fad90ab466510692ce44f41721abcef3509d165b77c54659113da
|
47b453b1cda5a48515575d4b5b22bc71fbf9bec08218840108a58ddaa963be58
|
@ -1 +1 @@
|
|||||||
9784ddeed1130181483eefe39228c9e70d2eba1026328fb3c9e8cbe8bac018e04fc6ef5c09dc1de840a1875ab6d5d56c67129dca6738adbefcc49e389c056390
|
1661c6ab616cdd0f4db6fa441a270e4b2581cbd2dddfd98132835e5646bd153717f7cd7f1fb9e3881ea3d23bae177d432631426b2a68add5029625a68d248519
|
@ -23,6 +23,7 @@ import com.xinbida.wukongim.interfaces.IGetOrSyncHistoryMsgBack;
|
|||||||
import com.xinbida.wukongim.manager.MsgManager;
|
import com.xinbida.wukongim.manager.MsgManager;
|
||||||
import com.xinbida.wukongim.message.type.WKSendMsgResult;
|
import com.xinbida.wukongim.message.type.WKSendMsgResult;
|
||||||
import com.xinbida.wukongim.protocol.WKMessageContent;
|
import com.xinbida.wukongim.protocol.WKMessageContent;
|
||||||
|
import com.xinbida.wukongim.utils.WKLoggerUtils;
|
||||||
import com.xinbida.wukongim.utils.WKTypeUtils;
|
import com.xinbida.wukongim.utils.WKTypeUtils;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -58,11 +59,14 @@ public class MsgDbManager {
|
|||||||
public void getOrSyncHistoryMessages(String channelId, byte channelType, long oldestOrderSeq, boolean contain, int pullMode, int limit, final IGetOrSyncHistoryMsgBack iGetOrSyncHistoryMsgBack) {
|
public void getOrSyncHistoryMessages(String channelId, byte channelType, long oldestOrderSeq, boolean contain, int pullMode, int limit, final IGetOrSyncHistoryMsgBack iGetOrSyncHistoryMsgBack) {
|
||||||
//获取原始数据
|
//获取原始数据
|
||||||
List<WKMsg> list = getMessages(channelId, channelType, oldestOrderSeq, contain, pullMode, limit);
|
List<WKMsg> list = getMessages(channelId, channelType, oldestOrderSeq, contain, pullMode, limit);
|
||||||
|
|
||||||
//业务判断数据
|
//业务判断数据
|
||||||
List<WKMsg> tempList = new ArrayList<>();
|
List<WKMsg> tempList = new ArrayList<>();
|
||||||
for (int i = 0, size = list.size(); i < size; i++) {
|
for (int i = 0, size = list.size(); i < size; i++) {
|
||||||
tempList.add(list.get(i));
|
tempList.add(list.get(i));
|
||||||
}
|
}
|
||||||
|
WKLoggerUtils.getInstance().e("查询参数oldestOrderSeq:" + oldestOrderSeq + ",contain:" + contain + ",pullMode" + pullMode + ",limit:" + limit + ",查询到的总数:" + tempList.size());
|
||||||
|
|
||||||
//先通过message_seq排序
|
//先通过message_seq排序
|
||||||
if (tempList.size() > 0)
|
if (tempList.size() > 0)
|
||||||
Collections.sort(tempList, (o1, o2) -> (o1.messageSeq - o2.messageSeq));
|
Collections.sort(tempList, (o1, o2) -> (o1.messageSeq - o2.messageSeq));
|
||||||
@ -89,21 +93,37 @@ public class MsgDbManager {
|
|||||||
if (oldestOrderSeq % 1000 != 0)
|
if (oldestOrderSeq % 1000 != 0)
|
||||||
oldestMsgSeq = getMsgSeq(channelId, channelType, oldestOrderSeq, pullMode);
|
oldestMsgSeq = getMsgSeq(channelId, channelType, oldestOrderSeq, pullMode);
|
||||||
else oldestMsgSeq = oldestOrderSeq / 1000;
|
else oldestMsgSeq = oldestOrderSeq / 1000;
|
||||||
|
WKLoggerUtils.getInstance().e("计算出的最大seq:" + maxMessageSeq + "最小seq:" + minMessageSeq + "及oldestMsgSeq:" + oldestMsgSeq);
|
||||||
if (pullMode == 0) {
|
if (pullMode == 0) {
|
||||||
//下拉获取消息
|
//下拉获取消息
|
||||||
if (maxMessageSeq != 0 && oldestMsgSeq != 0 && oldestMsgSeq - maxMessageSeq > 1) {
|
if (maxMessageSeq != 0 && oldestMsgSeq != 0) {
|
||||||
isSyncMsg = true;
|
isSyncMsg = true;
|
||||||
startMsgSeq = oldestMsgSeq;
|
// 从大往小同步
|
||||||
endMsgSeq = maxMessageSeq;
|
if (oldestMsgSeq - maxMessageSeq > 1) {
|
||||||
|
startMsgSeq = oldestMsgSeq;
|
||||||
|
endMsgSeq = maxMessageSeq;
|
||||||
|
} else {
|
||||||
|
startMsgSeq = maxMessageSeq;
|
||||||
|
endMsgSeq = oldestMsgSeq;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//上拉获取消息
|
//上拉获取消息
|
||||||
if (minMessageSeq != 0 && oldestMsgSeq != 0 && minMessageSeq - oldestMsgSeq > 1) {
|
if (minMessageSeq != 0 && oldestMsgSeq != 0) {
|
||||||
isSyncMsg = true;
|
isSyncMsg = true;
|
||||||
startMsgSeq = minMessageSeq;
|
// 从小往大同步
|
||||||
endMsgSeq = oldestMsgSeq;
|
if (minMessageSeq - oldestMsgSeq > 1) {
|
||||||
|
startMsgSeq = oldestMsgSeq;
|
||||||
|
endMsgSeq = minMessageSeq;
|
||||||
|
} else {
|
||||||
|
startMsgSeq = minMessageSeq;
|
||||||
|
endMsgSeq = oldestMsgSeq;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WKLoggerUtils.getInstance().e("第一次计算同步信息isSyncMsg:" + isSyncMsg + "最大seq:" + maxMessageSeq + ",最小seq:" + minMessageSeq + "及oldestMsgSeq:" + oldestMsgSeq);
|
||||||
|
|
||||||
if (!isSyncMsg) {
|
if (!isSyncMsg) {
|
||||||
//判断当前页是否连续
|
//判断当前页是否连续
|
||||||
@ -136,6 +156,7 @@ public class MsgDbManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WKLoggerUtils.getInstance().e("判断连续性同步信息isSyncMsg:" + isSyncMsg + "最大seq:" + maxMessageSeq + ",最小seq:" + minMessageSeq + "及oldestMsgSeq:" + oldestMsgSeq);
|
||||||
|
|
||||||
if (!isSyncMsg) {
|
if (!isSyncMsg) {
|
||||||
if (minMessageSeq == 1) {
|
if (minMessageSeq == 1) {
|
||||||
@ -158,6 +179,8 @@ public class MsgDbManager {
|
|||||||
endMsgSeq = 0;
|
endMsgSeq = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WKLoggerUtils.getInstance().e("计算本地消息总数小于limit后同步信息isSyncMsg:" + isSyncMsg + "最大seq:" + maxMessageSeq + ",最小seq:" + minMessageSeq + "及oldestMsgSeq:" + oldestMsgSeq);
|
||||||
|
|
||||||
if (isSyncMsg && startMsgSeq != endMsgSeq && requestCount < 5) {
|
if (isSyncMsg && startMsgSeq != endMsgSeq && requestCount < 5) {
|
||||||
//同步消息
|
//同步消息
|
||||||
requestCount++;
|
requestCount++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user