mirror of
https://github.com/WuKongIM/WuKongIMFlutterSDK
synced 2025-05-24 02:42:20 +00:00
parent
8a555c4833
commit
3a4d8aa536
25
.vscode/launch.json
vendored
25
.vscode/launch.json
vendored
@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "wukongimfluttersdk",
|
|
||||||
"request": "launch",
|
|
||||||
"type": "dart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "wukongimfluttersdk (profile mode)",
|
|
||||||
"request": "launch",
|
|
||||||
"type": "dart",
|
|
||||||
"flutterMode": "profile"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "wukongimfluttersdk (release mode)",
|
|
||||||
"request": "launch",
|
|
||||||
"type": "dart",
|
|
||||||
"flutterMode": "release"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"DockerRun.DisableDockerrc": true
|
||||||
|
}
|
@ -51,4 +51,4 @@ SPEC CHECKSUMS:
|
|||||||
|
|
||||||
PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189
|
PODFILE CHECKSUM: 70d9d25280d0dd177a5f637cdb0f0b0b12c6a189
|
||||||
|
|
||||||
COCOAPODS: 1.11.2
|
COCOAPODS: 1.14.3
|
||||||
|
@ -236,23 +236,23 @@ class ChatListDataState extends State<ChatList> {
|
|||||||
padding: const EdgeInsets.only(left: 0, top: 5, right: 0, bottom: 5),
|
padding: const EdgeInsets.only(left: 0, top: 5, right: 0, bottom: 5),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
// Container(
|
||||||
decoration: const BoxDecoration(
|
// decoration: const BoxDecoration(
|
||||||
shape: BoxShape.rectangle,
|
// shape: BoxShape.rectangle,
|
||||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
// borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||||
color: Color.fromARGB(255, 215, 80, 1)),
|
// color: Color.fromARGB(255, 215, 80, 1)),
|
||||||
width: 50,
|
// width: 50,
|
||||||
alignment: Alignment.center,
|
// alignment: Alignment.center,
|
||||||
height: 50,
|
// height: 50,
|
||||||
margin: const EdgeInsets.fromLTRB(0, 0, 10, 0),
|
// margin: const EdgeInsets.fromLTRB(0, 0, 10, 0),
|
||||||
child: Text(
|
// child: Text(
|
||||||
CommonUtils.getAvatar(uiMsg.wkMsg.fromUID),
|
// CommonUtils.getAvatar(uiMsg.wkMsg.fromUID),
|
||||||
style: const TextStyle(
|
// style: const TextStyle(
|
||||||
color: Colors.white,
|
// color: Colors.white,
|
||||||
fontSize: 20,
|
// fontSize: 20,
|
||||||
fontWeight: FontWeight.bold),
|
// fontWeight: FontWeight.bold),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import 'dart:ffi';
|
|
||||||
|
|
||||||
import 'package:example/const.dart';
|
import 'package:example/const.dart';
|
||||||
import 'package:wukongimfluttersdk/common/options.dart';
|
import 'package:wukongimfluttersdk/common/options.dart';
|
||||||
import 'package:wukongimfluttersdk/entity/channel.dart';
|
import 'package:wukongimfluttersdk/entity/channel.dart';
|
||||||
|
@ -37,7 +37,7 @@ class _InputDialogState extends State<InputDialog> {
|
|||||||
children: [
|
children: [
|
||||||
TextField(
|
TextField(
|
||||||
controller: _textEditingController,
|
controller: _textEditingController,
|
||||||
maxLength: 12,
|
maxLength: 120,
|
||||||
onChanged: (v) {
|
onChanged: (v) {
|
||||||
channelID = v;
|
channelID = v;
|
||||||
},
|
},
|
||||||
|
@ -45,4 +45,4 @@ SPEC CHECKSUMS:
|
|||||||
|
|
||||||
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
|
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
|
||||||
|
|
||||||
COCOAPODS: 1.11.2
|
COCOAPODS: 1.14.3
|
||||||
|
@ -259,7 +259,7 @@
|
|||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
attributes = {
|
attributes = {
|
||||||
LastSwiftUpdateCheck = 0920;
|
LastSwiftUpdateCheck = 0920;
|
||||||
LastUpgradeCheck = 1430;
|
LastUpgradeCheck = 1300;
|
||||||
ORGANIZATIONNAME = "";
|
ORGANIZATIONNAME = "";
|
||||||
TargetAttributes = {
|
TargetAttributes = {
|
||||||
331C80D4294CF70F00263BE5 = {
|
331C80D4294CF70F00263BE5 = {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1430"
|
LastUpgradeVersion = "1300"
|
||||||
version = "1.3">
|
version = "1.3">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
|
@ -61,10 +61,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.18.0"
|
version: "1.17.1"
|
||||||
connectivity:
|
connectivity:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -244,26 +244,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.16"
|
version: "0.12.15"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.5.0"
|
version: "0.2.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
|
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.9.1"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -385,10 +385,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_span
|
name: source_span
|
||||||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.9.1"
|
||||||
sqflite:
|
sqflite:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -409,18 +409,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.11.1"
|
version: "1.11.0"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.1"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -449,10 +449,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
|
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
|
||||||
url: "https://pub.flutter-io.cn"
|
url: "https://pub.flutter-io.cn"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.1"
|
version: "0.5.1"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -477,14 +477,6 @@ 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:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: web
|
|
||||||
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
|
|
||||||
url: "https://pub.flutter-io.cn"
|
|
||||||
source: hosted
|
|
||||||
version: "0.3.0"
|
|
||||||
web_socket_channel:
|
web_socket_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -507,7 +499,7 @@ packages:
|
|||||||
path: ".."
|
path: ".."
|
||||||
relative: true
|
relative: true
|
||||||
source: path
|
source: path
|
||||||
version: "1.1.8"
|
version: "1.1.9"
|
||||||
x25519:
|
x25519:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -525,5 +517,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.0.6 <4.0.0"
|
||||||
flutter: ">=3.3.0"
|
flutter: ">=3.3.0"
|
||||||
|
@ -20,29 +20,44 @@ import '../proto/proto.dart';
|
|||||||
import '../type/const.dart';
|
import '../type/const.dart';
|
||||||
|
|
||||||
class _WKSocket {
|
class _WKSocket {
|
||||||
final Socket _socket;
|
Socket? _socket; // 将 _socket 声明为可空类型
|
||||||
_WKSocket.newSocket(this._socket);
|
bool _isListening = false;
|
||||||
|
static _WKSocket? _instance;
|
||||||
|
|
||||||
|
_WKSocket._internal(this._socket);
|
||||||
|
|
||||||
|
factory _WKSocket.newSocket(Socket socket) {
|
||||||
|
_instance ??= _WKSocket._internal(socket);
|
||||||
|
return _instance!;
|
||||||
|
}
|
||||||
|
|
||||||
void close() {
|
void close() {
|
||||||
_socket.close();
|
_socket?.close();
|
||||||
|
_isListening = false;
|
||||||
|
_socket = null; // 现在可以将 _socket 设置为 null
|
||||||
|
_instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void send(Uint8List data) {
|
void send(Uint8List data) {
|
||||||
try {
|
try {
|
||||||
print('发消息');
|
_socket?.add(data); // 使用安全调用操作符
|
||||||
_socket.add(data);
|
_socket?.flush();
|
||||||
_socket.flush();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Logs.debug('发送消息错误');
|
Logs.debug('发送消息错误$e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void listen(void Function(Uint8List data) onData, void Function() error) {
|
void listen(void Function(Uint8List data) onData, void Function() error) {
|
||||||
_socket.listen(onData, onError: (err) {
|
if (!_isListening && _socket != null) {
|
||||||
Logs.debug('socket断开了${err.toString()}');
|
_socket!.listen(onData, onError: (err) {
|
||||||
}, onDone: () {
|
Logs.debug('socket断开了${err.toString()}');
|
||||||
Logs.debug('socketonDone');
|
}, onDone: () {
|
||||||
error();
|
Logs.debug('socketonDone');
|
||||||
});
|
error();
|
||||||
|
close(); // 关闭和重置 Socket 连接
|
||||||
|
});
|
||||||
|
_isListening = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,7 +160,7 @@ class WKConnectionManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isReconnection = true;
|
isReconnection = true;
|
||||||
Logs.error('发送消息失败');
|
Logs.error('发送消息失败$_isLogout');
|
||||||
Future.delayed(Duration(milliseconds: reconnMilliseconds), () {
|
Future.delayed(Duration(milliseconds: reconnMilliseconds), () {
|
||||||
connect();
|
connect();
|
||||||
});
|
});
|
||||||
@ -155,7 +170,9 @@ class WKConnectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_connectFail(error) {
|
_connectFail(error) {
|
||||||
|
// _socket?.close();
|
||||||
Logs.error('连接失败:${error.toString()}');
|
Logs.error('连接失败:${error.toString()}');
|
||||||
|
print(error);
|
||||||
Future.delayed(Duration(milliseconds: reconnMilliseconds), () {
|
Future.delayed(Duration(milliseconds: reconnMilliseconds), () {
|
||||||
connect();
|
connect();
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user