From 5dd1ef6d4799de0372fd837fa70f912f0c08df73 Mon Sep 17 00:00:00 2001 From: Jin857 Date: Mon, 6 Jan 2025 17:05:54 +0800 Subject: [PATCH] =?UTF-8?q?=20=E6=B7=BB=E5=8A=A0=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dart_tool/package_config.json | 8 +++++++- .dart_tool/package_config_subset | 4 ++++ .flutter-plugins-dependencies | 2 +- README.md | 13 +++++++++++++ example/.dart_tool/package_config.json | 8 +++++++- example/.dart_tool/package_config_subset | 4 ++++ example/.flutter-plugins-dependencies | 2 +- example/pubspec.lock | 8 ++++++++ lib/entity/msg.dart | 13 +++++++++++++ lib/manager/message_manager.dart | 1 + pubspec.lock | 8 ++++++++ pubspec.yaml | 1 + 12 files changed, 68 insertions(+), 4 deletions(-) diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 4b86d89..74b784a 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -253,6 +253,12 @@ "packageUri": "lib/", "languageVersion": "2.12" }, + { + "name": "ntp", + "rootUri": "file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/ntp-2.0.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, { "name": "path", "rootUri": "file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path-1.9.0", @@ -524,7 +530,7 @@ "languageVersion": "3.0" } ], - "generated": "2025-01-04T01:05:13.928344Z", + "generated": "2025-01-06T08:25:10.616604Z", "generator": "pub", "generatorVersion": "3.5.4", "flutterRoot": "file:///Users/jin/development/flutter", diff --git a/.dart_tool/package_config_subset b/.dart_tool/package_config_subset index 71aae28..e135bcc 100644 --- a/.dart_tool/package_config_subset +++ b/.dart_tool/package_config_subset @@ -154,6 +154,10 @@ meta 2.12 file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/meta-1.15.0/ file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/meta-1.15.0/lib/ +ntp +2.12 +file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/ntp-2.0.0/ +file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/ntp-2.0.0/lib/ path 3.0 file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path-1.9.0/ diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 7fdaa0d..99bbf03 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity-3.0.6/","native_build":true,"dependencies":[]},{"name":"encryptions","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/encryptions-1.1.0+1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite_darwin","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_darwin-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"connectivity","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity-3.0.6/","native_build":true,"dependencies":[]},{"name":"encryptions","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/encryptions-1.1.0+1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_android-2.4.0/","native_build":true,"dependencies":[]},{"name":"sqflite_android","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_android-2.4.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity_macos-0.2.1+2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite_darwin","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_darwin-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_for_web","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity_for_web-0.4.0+1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos","connectivity_for_web"]},{"name":"connectivity_for_web","dependencies":[]},{"name":"connectivity_macos","dependencies":[]},{"name":"encryptions","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":["sqflite_android","sqflite_darwin"]},{"name":"sqflite_android","dependencies":[]},{"name":"sqflite_darwin","dependencies":[]}],"date_created":"2025-01-04 09:05:14.467167","version":"3.24.4","swift_package_manager_enabled":false} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity-3.0.6/","native_build":true,"dependencies":[]},{"name":"encryptions","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/encryptions-1.1.0+1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite_darwin","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_darwin-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"connectivity","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity-3.0.6/","native_build":true,"dependencies":[]},{"name":"encryptions","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/encryptions-1.1.0+1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_android-2.4.0/","native_build":true,"dependencies":[]},{"name":"sqflite_android","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_android-2.4.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity_macos-0.2.1+2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite_darwin","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_darwin-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_for_web","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity_for_web-0.4.0+1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos","connectivity_for_web"]},{"name":"connectivity_for_web","dependencies":[]},{"name":"connectivity_macos","dependencies":[]},{"name":"encryptions","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":["sqflite_android","sqflite_darwin"]},{"name":"sqflite_android","dependencies":[]},{"name":"sqflite_darwin","dependencies":[]}],"date_created":"2025-01-06 16:25:11.042092","version":"3.24.4","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/README.md b/README.md index 43b207e..4cc91f3 100644 --- a/README.md +++ b/README.md @@ -84,5 +84,18 @@ WKIM.shared.cmdManager.addOnCmdListener('chat', (cmdMsg) { ``` - 包含`key`的事件监听均有移除监听的方法,为了避免重复收到事件回掉,在退出或销毁页面时通过传入的`key`移除事件 +**发送消息时间** +[使用](https://blog.csdn.net/weixin_37813152/article/details/128712718) +[网络协议] NTP(Network Time Protocol)协议 +使用阿里时间 +ntp.aliyun.com +ntp1.aliyun.com +ntp2.aliyun.com +ntp3.aliyun.com +ntp4.aliyun.com +ntp5.aliyun.com +ntp6.aliyun.com +ntp7.aliyun.com + ### 许可证 悟空IM 使用 Apache 2.0 许可证。有关详情,请参阅 LICENSE 文件。 \ No newline at end of file diff --git a/example/.dart_tool/package_config.json b/example/.dart_tool/package_config.json index ffc10e7..f56b384 100644 --- a/example/.dart_tool/package_config.json +++ b/example/.dart_tool/package_config.json @@ -253,6 +253,12 @@ "packageUri": "lib/", "languageVersion": "2.12" }, + { + "name": "ntp", + "rootUri": "file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/ntp-2.0.0", + "packageUri": "lib/", + "languageVersion": "2.12" + }, { "name": "path", "rootUri": "file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path-1.9.0", @@ -530,7 +536,7 @@ "languageVersion": "2.17" } ], - "generated": "2025-01-04T01:05:14.116758Z", + "generated": "2025-01-06T08:25:08.002643Z", "generator": "pub", "generatorVersion": "3.5.4", "flutterRoot": "file:///Users/jin/development/flutter", diff --git a/example/.dart_tool/package_config_subset b/example/.dart_tool/package_config_subset index 95c861f..4b69073 100644 --- a/example/.dart_tool/package_config_subset +++ b/example/.dart_tool/package_config_subset @@ -154,6 +154,10 @@ meta 2.12 file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/meta-1.15.0/ file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/meta-1.15.0/lib/ +ntp +2.12 +file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/ntp-2.0.0/ +file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/ntp-2.0.0/lib/ path 3.0 file:///Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path-1.9.0/ diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index 56a0b5b..b6ab3aa 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity-3.0.6/","native_build":true,"dependencies":[]},{"name":"encryptions","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/encryptions-1.1.0+1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite_darwin","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_darwin-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"connectivity","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity-3.0.6/","native_build":true,"dependencies":[]},{"name":"encryptions","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/encryptions-1.1.0+1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_android-2.4.0/","native_build":true,"dependencies":[]},{"name":"sqflite_android","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_android-2.4.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity_macos-0.2.1+2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite_darwin","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_darwin-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_for_web","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity_for_web-0.4.0+1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos","connectivity_for_web"]},{"name":"connectivity_for_web","dependencies":[]},{"name":"connectivity_macos","dependencies":[]},{"name":"encryptions","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":["sqflite_android","sqflite_darwin"]},{"name":"sqflite_android","dependencies":[]},{"name":"sqflite_darwin","dependencies":[]}],"date_created":"2025-01-04 09:05:14.658280","version":"3.24.4","swift_package_manager_enabled":false} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity-3.0.6/","native_build":true,"dependencies":[]},{"name":"encryptions","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/encryptions-1.1.0+1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite_darwin","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_darwin-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"connectivity","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity-3.0.6/","native_build":true,"dependencies":[]},{"name":"encryptions","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/encryptions-1.1.0+1/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_android-2.4.0/","native_build":true,"dependencies":[]},{"name":"sqflite_android","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_android-2.4.0/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_macos","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity_macos-0.2.1+2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite_darwin","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/sqflite_darwin-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_for_web","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/connectivity_for_web-0.4.0+1/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/jin/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity","dependencies":["connectivity_macos","connectivity_for_web"]},{"name":"connectivity_for_web","dependencies":[]},{"name":"connectivity_macos","dependencies":[]},{"name":"encryptions","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":["sqflite_android","sqflite_darwin"]},{"name":"sqflite_android","dependencies":[]},{"name":"sqflite_darwin","dependencies":[]}],"date_created":"2025-01-06 16:25:08.584585","version":"3.24.4","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index 84ff1f5..dc5d300 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -328,6 +328,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.15.0" + ntp: + dependency: transitive + description: + name: ntp + sha256: "198db73e5059b334b50dbe8c626011c26576778ee9fc53f4c55c1d89d08ed2d2" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" path: dependency: transitive description: diff --git a/lib/entity/msg.dart b/lib/entity/msg.dart index 25eaf1e..c142a2d 100644 --- a/lib/entity/msg.dart +++ b/lib/entity/msg.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:ntp/ntp.dart'; import 'package:wukongimfluttersdk/db/const.dart'; import 'package:wukongimfluttersdk/wkim.dart'; @@ -46,6 +47,18 @@ class WKMsg { timestamp = (DateTime.now().millisecondsSinceEpoch / 1000).truncate(); } + getNetworkTime() async { + try { + DateTime ntpTime = await NTP.now( + lookUpAddress: "ntp.aliyun.com", + port: 123, + ); // 获取 NTP 网络时间 + return (ntpTime.millisecondsSinceEpoch / 1000).truncate(); + } catch (e) { + return (DateTime.now().millisecondsSinceEpoch / 1000).truncate(); + } + } + setChannelInfo(WKChannel? wkChannel) { _channelInfo = wkChannel; } diff --git a/lib/manager/message_manager.dart b/lib/manager/message_manager.dart index 9d2273d..3a7ab00 100644 --- a/lib/manager/message_manager.dart +++ b/lib/manager/message_manager.dart @@ -597,6 +597,7 @@ class WKMessageManager { sendWithOption(WKMessageContent messageContent, WKChannel channel, WKSendOptions options) async { WKMsg wkMsg = WKMsg(); + wkMsg.timestamp = await wkMsg.getNetworkTime(); wkMsg.setting = options.setting; wkMsg.header = options.header; wkMsg.messageContent = messageContent; diff --git a/pubspec.lock b/pubspec.lock index 623f355..77cca88 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -328,6 +328,14 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.15.0" + ntp: + dependency: "direct main" + description: + name: ntp + sha256: "198db73e5059b334b50dbe8c626011c26576778ee9fc53f4c55c1d89d08ed2d2" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" path: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index de7c9c0..fb66399 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -51,6 +51,7 @@ dependencies: html: ^0.15.5 sqflite_common_ffi: ^2.3.4+4 sqflite_common_ffi_web: ^0.4.5+4 + ntp: ^2.0.0 dev_dependencies: flutter_test: