fix: Optimize synchronization channel messages

This commit is contained in:
SL 2024-06-04 22:17:44 +08:00
parent 53e7be54fc
commit bf378ca075
11 changed files with 90 additions and 61 deletions

View File

@ -81,4 +81,6 @@
### 1.4.0 ### 1.4.0
* fix: Modifying the issue of a large number of offline messages getting stuck during synchronization * fix: Modifying the issue of a large number of offline messages getting stuck during synchronization
### 1.4.1 ### 1.4.1
* fix: Modifying non JSON serialization errors in extended fields * fix: Modifying non JSON serialization errors in extended fields
### 1.4.2
* fix: Optimize synchronization channel messages

View File

@ -21,6 +21,6 @@
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0</string> <string>1.0</string>
<key>MinimumOSVersion</key> <key>MinimumOSVersion</key>
<string>11.0</string> <string>12.0</string>
</dict> </dict>
</plist> </plist>

View File

@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project # Uncomment this line to define a global platform for your project
# platform :ios, '11.0' # platform :ios, '12.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency. # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true' ENV['COCOAPODS_DISABLE_STATS'] = 'true'

View File

@ -5,27 +5,23 @@ PODS:
- encryptions (0.0.1): - encryptions (0.0.1):
- Flutter - Flutter
- Flutter (1.0.0) - Flutter (1.0.0)
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- Reachability (3.2) - Reachability (3.2)
- shared_preferences_foundation (0.0.1): - shared_preferences_foundation (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- sqflite (0.0.2): - sqflite (0.0.3):
- Flutter - Flutter
- FMDB (>= 2.7.5) - FlutterMacOS
DEPENDENCIES: DEPENDENCIES:
- connectivity (from `.symlinks/plugins/connectivity/ios`) - connectivity (from `.symlinks/plugins/connectivity/ios`)
- encryptions (from `.symlinks/plugins/encryptions/ios`) - encryptions (from `.symlinks/plugins/encryptions/ios`)
- Flutter (from `Flutter`) - Flutter (from `Flutter`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/ios`) - sqflite (from `.symlinks/plugins/sqflite/darwin`)
SPEC REPOS: SPEC REPOS:
trunk: trunk:
- FMDB
- Reachability - Reachability
EXTERNAL SOURCES: EXTERNAL SOURCES:
@ -38,17 +34,16 @@ EXTERNAL SOURCES:
shared_preferences_foundation: shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin" :path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite: sqflite:
:path: ".symlinks/plugins/sqflite/ios" :path: ".symlinks/plugins/sqflite/darwin"
SPEC CHECKSUMS: SPEC CHECKSUMS:
connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467 connectivity: c4130b2985d4ef6fd26f9702e886bd5260681467
encryptions: a374d8610fbe88a7f00a14e059ff1df3f100d9e2 encryptions: a374d8610fbe88a7f00a14e059ff1df3f100d9e2
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126 shared_preferences_foundation: 5b919d13b803cadd15ed2dc053125c68730e5126
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189 PODFILE CHECKSUM: 819463e6a0290f5a72f145ba7cde16e8b6ef0796
COCOAPODS: 1.11.2 COCOAPODS: 1.11.2

View File

@ -214,7 +214,7 @@
97C146E61CF9000F007C117D /* Project object */ = { 97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 1430; LastUpgradeCheck = 1510;
ORGANIZATIONNAME = ""; ORGANIZATIONNAME = "";
TargetAttributes = { TargetAttributes = {
331C8080294A63A400263BE5 = { 331C8080294A63A400263BE5 = {
@ -451,7 +451,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;
@ -579,7 +579,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES; MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES; ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos; SDKROOT = iphoneos;
@ -628,7 +628,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES; GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO; MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos; SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos; SUPPORTED_PLATFORMS = iphoneos;

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1430" LastUpgradeVersion = "1510"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"

View File

@ -155,7 +155,8 @@ class ChatListDataState extends State<ChatList> {
getMsgList(int oldestOrderSeq, int pullMode, bool isReset) { getMsgList(int oldestOrderSeq, int pullMode, bool isReset) {
WKIM.shared.messageManager.getOrSyncHistoryMessages(channelID, channelType, WKIM.shared.messageManager.getOrSyncHistoryMessages(channelID, channelType,
oldestOrderSeq, oldestOrderSeq == 0, pullMode, 10, 0, (list) { oldestOrderSeq, oldestOrderSeq == 0, pullMode, 5, 0, (list) {
print('同步完成${list.length}条消息');
List<UIMsg> uiList = []; List<UIMsg> uiList = [];
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
if (pullMode == 0 && !isReset) { if (pullMode == 0 && !isReset) {

View File

@ -80,6 +80,7 @@ class HttpUtils {
int pullMode, int pullMode,
Function(WKSyncChannelMsg) back) async { Function(WKSyncChannelMsg) back) async {
final dio = Dio(); final dio = Dio();
print('开始seq: $startMsgSeq 结束seq: $endMsgSeq');
final response = await dio.post('$apiURL/channel/messagesync', data: { final response = await dio.post('$apiURL/channel/messagesync', data: {
"login_uid": UserInfo.uid, // uid "login_uid": UserInfo.uid, // uid
"channel_id": channelID, // ID "channel_id": channelID, // ID
@ -96,6 +97,7 @@ class HttpUtils {
msg.endMessageSeq = data['end_message_seq']; msg.endMessageSeq = data['end_message_seq'];
msg.more = data['more']; msg.more = data['more'];
var messages = data['messages'] as List<dynamic>; var messages = data['messages'] as List<dynamic>;
List<WKSyncMsg> msgList = []; List<WKSyncMsg> msgList = [];
for (int i = 0; i < messages.length; i++) { for (int i = 0; i < messages.length; i++) {
dynamic json = messages[i]; dynamic json = messages[i];

View File

@ -232,6 +232,30 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.6.5" version: "0.6.5"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
url: "https://pub.flutter-io.cn"
source: hosted
version: "10.0.4"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.3"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
@ -244,34 +268,34 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.16" version: "0.12.16+1"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.5.0" version: "0.8.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.10.0" version: "1.12.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.3" version: "1.9.0"
path_provider_linux: path_provider_linux:
dependency: transitive dependency: transitive
description: description:
@ -389,22 +413,30 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
sprintf:
dependency: transitive
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.flutter-io.cn"
source: hosted
version: "7.0.0"
sqflite: sqflite:
dependency: transitive dependency: transitive
description: description:
name: sqflite name: sqflite
sha256: b3a8307b9519af28518e271e548594bdc435225fc77e8fb22e71a296c69281cf sha256: a43e5a27235518c03ca238e7b4732cf35eabe863a369ceba6cbefa537a66f16d
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.3+1" version: "2.3.3+1"
sqflite_common: sqflite_common:
dependency: transitive dependency: transitive
description: description:
name: sqflite_common name: sqflite_common
sha256: "8f7603f3f8f126740bc55c4ca2d1027aab4b74a1267a3e31ce51fe40e3b65b8f" sha256: "3da423ce7baf868be70e2c0976c28a1bb2f73644268b7ffa7d2e08eab71f16a4"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.4.5+1" version: "2.5.4"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@ -449,10 +481,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.6.1" version: "0.7.0"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@ -465,10 +497,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: uuid name: uuid
sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "3.0.7" version: "4.4.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
@ -477,14 +509,14 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.4" version: "2.1.4"
web: vm_service:
dependency: transitive dependency: transitive
description: description:
name: web name: vm_service
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.3.0" version: "14.2.1"
web_socket_channel: web_socket_channel:
dependency: transitive dependency: transitive
description: description:
@ -507,7 +539,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "1.2.4" version: "1.4.1"
x25519: x25519:
dependency: transitive dependency: transitive
description: description:
@ -525,5 +557,5 @@ packages:
source: hosted source: hosted
version: "1.0.2" version: "1.0.2"
sdks: sdks:
dart: ">=3.2.0-194.0.dev <4.0.0" dart: ">=3.3.0 <4.0.0"
flutter: ">=3.3.0" flutter: ">=3.18.0-18.0.pre.54"

View File

@ -450,25 +450,22 @@ class MessageDB {
// //
int syncLimit = limit; int syncLimit = limit;
if (!isSyncMsg && tempList.length < limit) { if (!isSyncMsg && tempList.length < limit) {
if (pullMode == 0) { isSyncMsg = true;
// if (contain) {
isSyncMsg = true; startMsgSeq = oldestMsgSeq;
// startMsgSeq = oldestMsgSeq;
startMsgSeq = minMessageSeq; // seq开始同步
if (!contain) {
syncLimit = syncLimit + 1;
}
endMsgSeq = 0;
} else { } else {
// if (pullMode == 0) {
isSyncMsg = true; startMsgSeq = oldestMsgSeq - 1;
// startMsgSeq = oldestMsgSeq; } else {
startMsgSeq = maxMessageSeq; // seq开始同步 startMsgSeq = oldestMsgSeq + 1;
endMsgSeq = 0;
if (!contain) {
syncLimit = syncLimit + 1;
} }
} }
endMsgSeq = 0;
}
if (startMsgSeq == 0 && endMsgSeq == 0 && tempList.length < limit) {
isSyncMsg = true;
endMsgSeq = oldestMsgSeq;
startMsgSeq = 0;
} }
if (isSyncMsg && if (isSyncMsg &&
(startMsgSeq != endMsgSeq || (startMsgSeq == 0 && endMsgSeq == 0)) && (startMsgSeq != endMsgSeq || (startMsgSeq == 0 && endMsgSeq == 0)) &&

View File

@ -15,7 +15,7 @@ description: wukong IM flutter sdk
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.4.1 version: 1.4.2
homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK homepage: https://github.com/WuKongIM/WuKongIMFlutterSDK
environment: environment: