添加时间协议

This commit is contained in:
Jin857 2025-01-06 17:05:54 +08:00
parent 8378e4331e
commit 5dd1ef6d47
12 changed files with 68 additions and 4 deletions

View File

@ -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",

View File

@ -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/

View File

@ -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}
{"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}

View File

@ -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 文件。

View File

@ -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",

View File

@ -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/

View File

@ -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}
{"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}

View File

@ -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:

View File

@ -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;
}

View File

@ -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;

View File

@ -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:

View File

@ -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: