mirror of
https://gitee.com/farsunset/cim.git
synced 2025-06-17 07:35:25 +08:00
flutter sdk 长连接登录信息 改为缺省参数 可自行填写
This commit is contained in:
parent
df3385151a
commit
37bb7a06bc
@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":false,"dependencies":[]}],"web":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]}],"date_created":"2023-07-14 10:36:34.428685","version":"3.7.7"}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":false,"dependencies":[]}],"web":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]}],"date_created":"2023-07-17 09:14:10.336893","version":"3.7.7"}
|
@ -1,3 +1,3 @@
|
||||
## 1.0.5
|
||||
## 1.0.6
|
||||
|
||||
* allow connect string uid type are string. update readme.md
|
||||
* allow Custom login parameters.
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
```
|
||||
dependencies:
|
||||
cim_flutter_sdk: ^1.0.5
|
||||
cim_flutter_sdk: ^1.0.6
|
||||
```
|
||||
|
||||
|
||||
@ -43,7 +43,13 @@ import 'package:cim_flutter_sdk/cim_socket.dart';
|
||||
});
|
||||
});
|
||||
cimSocket!.init('127.0.0.1', 34567, '16501516154949');
|
||||
cimSocket!.connect();
|
||||
cimSocket!.connect(
|
||||
devicename: "Windows 10 Pro",
|
||||
appVersion: "2.1.0",
|
||||
osVersion: "10.0.19042.1165",
|
||||
packageName: "com.farsunset.flutter",
|
||||
deviceid: "asd52d1d0a6s1f6sdf1",
|
||||
language: "zh_CN");
|
||||
}
|
||||
...
|
||||
|
||||
|
@ -15,7 +15,7 @@ migration:
|
||||
- platform: root
|
||||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
||||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
||||
- platform: web
|
||||
- platform: windows
|
||||
create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
||||
base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
import 'package:cim_flutter_sdk/cim_socket.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
@ -35,7 +32,13 @@ class _MyAppState extends State<MyApp> {
|
||||
});
|
||||
});
|
||||
cimSocket!.init('api.hoxin.farsunset.com', 34567, '16501516154949');
|
||||
cimSocket!.connect();
|
||||
cimSocket!.connect(
|
||||
devicename: "Windows 10 Pro",
|
||||
appVersion: "2.1.0",
|
||||
osVersion: "10.0.19042.1165",
|
||||
packageName: "com.farsunset.flutter",
|
||||
deviceid: "asd52d1d0a6s1f6sdf1",
|
||||
language: "zh_CN");
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -31,7 +31,7 @@ packages:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.5"
|
||||
version: "1.0.6"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -59,6 +59,20 @@ class CIMSocket {
|
||||
}
|
||||
});
|
||||
|
||||
late String? devicename;
|
||||
|
||||
late String? appVersion;
|
||||
|
||||
late String? osVersion;
|
||||
|
||||
late String? packageName;
|
||||
|
||||
late String? deviceid;
|
||||
|
||||
late String? language;
|
||||
|
||||
late String? channelName;
|
||||
|
||||
Future init(String uri, int port, String uid) async {
|
||||
this.uri = uri;
|
||||
this.port = port;
|
||||
@ -66,7 +80,22 @@ class CIMSocket {
|
||||
}
|
||||
|
||||
//登录
|
||||
Future connect() async {
|
||||
Future connect(
|
||||
{String? devicename,
|
||||
String? appVersion,
|
||||
String? osVersion,
|
||||
String? packageName,
|
||||
String? deviceid,
|
||||
String? language,
|
||||
String? channelName}) async {
|
||||
this.devicename = devicename;
|
||||
this.appVersion = appVersion;
|
||||
this.osVersion = osVersion;
|
||||
this.packageName = packageName;
|
||||
this.deviceid = deviceid;
|
||||
this.language = language;
|
||||
this.channelName = channelName;
|
||||
|
||||
if (uri == null || port == null || uid == null) {
|
||||
throw IOException;
|
||||
}
|
||||
@ -124,23 +153,25 @@ class CIMSocket {
|
||||
Future sendLoginMsg() async {
|
||||
SystemInfo systemInfo = SystemInfo();
|
||||
await systemInfo.init();
|
||||
String deviceName = systemInfo.deviceName;
|
||||
String deviceName = devicename ?? systemInfo.deviceName;
|
||||
// DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
String channel = systemInfo.deviceName;
|
||||
String systemVersion = systemInfo.version;
|
||||
String deviceId = hex.encode(
|
||||
md5.convert(const Utf8Encoder().convert(systemInfo.deviceId)).bytes);
|
||||
String channel = channelName ?? systemInfo.deviceName;
|
||||
String systemVersion = osVersion ?? systemInfo.version;
|
||||
String deviceId = deviceid ??
|
||||
hex.encode(md5
|
||||
.convert(const Utf8Encoder().convert(systemInfo.deviceId))
|
||||
.bytes);
|
||||
|
||||
Map<String, String> map = {
|
||||
"uid": uid!, //主id
|
||||
"channel": channel,
|
||||
"appVersion": sOCKETAPPVERSION,
|
||||
"appVersion": appVersion ?? sOCKETAPPVERSION,
|
||||
"osVersion": systemVersion,
|
||||
"packageName": "cn.asihe.cim",
|
||||
"packageName": packageName ?? "cn.asihe.cim",
|
||||
"deviceId": deviceId,
|
||||
// (await PlatformDeviceId.getDeviceId)!.replaceAll("-", ""), //应用id
|
||||
"deviceName": '$deviceName ${systemInfo.model}',
|
||||
"language": "zh-CN",
|
||||
"language": language ?? "zh-CN",
|
||||
};
|
||||
int time = DateTime.now().millisecondsSinceEpoch;
|
||||
Int64 timeStamp = Int64.parseInt(time.toString());
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: cim_flutter_sdk
|
||||
description: a flutter sdk for cim. cim is a livechat framework use java netty, support user connect server by tcp or websocket.
|
||||
repository: https://gitee.com/farsunset/cim
|
||||
version: 1.0.5
|
||||
version: 1.0.6
|
||||
homepage: https://farsunset.com/
|
||||
|
||||
environment:
|
||||
|
@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":false,"dependencies":[]}],"web":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]}],"date_created":"2023-07-14 10:21:28.864244","version":"3.7.7"}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","native_build":false,"dependencies":[]}],"web":[{"name":"device_info_plus","path":"C:\\\\Users\\\\smeb\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\device_info_plus-8.2.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]}],"date_created":"2023-07-17 09:27:39.500003","version":"3.7.7"}
|
@ -1,3 +1,3 @@
|
||||
## 1.0.0
|
||||
## 1.0.1
|
||||
|
||||
* TODO: release a primary version. only support websocket
|
||||
* allow Custom login parameters.
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
```
|
||||
dependencies:
|
||||
cim_flutter_websocket_sdk: ^1.0.0
|
||||
cim_flutter_websocket_sdk: ^1.0.1
|
||||
```
|
||||
|
||||
|
||||
@ -43,7 +43,14 @@ import 'package:cim_flutter_sdk/cim_socket.dart';
|
||||
});
|
||||
});
|
||||
cimSocket!.init('127.0.0.1', 45678, '16501516154949', true);
|
||||
cimSocket!.connect();
|
||||
cimSocket!.connect(
|
||||
devicename: "Windows 10 Pro",
|
||||
appVersion: "1.0.0",
|
||||
osVersion: "10.0.19042",
|
||||
packageName: "com.farsunset.cim",
|
||||
deviceid: "16501516154949",
|
||||
language: "zh-CN",
|
||||
channelName: "web");
|
||||
}
|
||||
...
|
||||
|
||||
|
@ -32,7 +32,14 @@ class _MyAppState extends State<MyApp> {
|
||||
});
|
||||
});
|
||||
cimSocket!.init('wss.hoxin.farsunset.com', 443, '16501516154949', true);
|
||||
cimSocket!.connect();
|
||||
cimSocket!.connect(
|
||||
devicename: "Windows 10 Pro",
|
||||
appVersion: "1.0.0",
|
||||
osVersion: "10.0.19042",
|
||||
packageName: "com.farsunset.cim",
|
||||
deviceid: "16501516154949",
|
||||
language: "zh-CN",
|
||||
channelName: "web");
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -31,7 +31,7 @@ packages:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.0.0"
|
||||
version: "1.0.1"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -69,6 +69,27 @@ class CIMSocket {
|
||||
/// 连接状态回调
|
||||
final ValueChanged<String> onConnectionStatusChanged;
|
||||
|
||||
/// 设备名
|
||||
late String? devicename;
|
||||
|
||||
/// app版本
|
||||
late String? appVersion;
|
||||
|
||||
/// 系统版本
|
||||
late String? osVersion;
|
||||
|
||||
/// 包名
|
||||
late String? packageName;
|
||||
|
||||
/// 设备id
|
||||
late String? deviceid;
|
||||
|
||||
/// 语言
|
||||
late String? language;
|
||||
|
||||
///
|
||||
late String? channelName;
|
||||
|
||||
///
|
||||
/// [uri] 地址
|
||||
/// [port] 端口
|
||||
@ -81,12 +102,35 @@ class CIMSocket {
|
||||
this.useSsl = useSsl;
|
||||
}
|
||||
|
||||
//登录
|
||||
Future connect() async {
|
||||
/// 连接
|
||||
/// [devicename] 设备名
|
||||
/// [appVersion] app版本
|
||||
/// [osVersion] 系统版本
|
||||
/// [packageName] 包名
|
||||
/// [deviceid] 设备id
|
||||
/// [language] 语言
|
||||
/// [channelName] 渠道名
|
||||
Future connect({
|
||||
String? devicename,
|
||||
String? appVersion,
|
||||
String? osVersion,
|
||||
String? packageName,
|
||||
String? deviceid,
|
||||
String? language,
|
||||
String? channelName,
|
||||
}) async {
|
||||
if (uri == null || port == null || uid == null) {
|
||||
throw IOException;
|
||||
}
|
||||
|
||||
this.devicename = devicename;
|
||||
this.appVersion = appVersion;
|
||||
this.osVersion = osVersion;
|
||||
this.packageName = packageName;
|
||||
this.deviceid = deviceid;
|
||||
this.language = language;
|
||||
this.channelName = channelName;
|
||||
|
||||
channel = WebSocket(Uri.parse('${useSsl ? 'wss' : 'ws'}://$uri:$port'),
|
||||
backoff: ConstantBackoff(Duration(seconds: 10)),
|
||||
binaryType: 'arraybuffer');
|
||||
@ -109,12 +153,10 @@ class CIMSocket {
|
||||
var message = data.sublist(1, data.length);
|
||||
replybody.Model info = replybody.Model();
|
||||
info.mergeFromBuffer(message);
|
||||
print(info.toProto3Json().toString());
|
||||
} else if (data[0] == Message_TYPE) {
|
||||
var message = data.sublist(1, data.length);
|
||||
messages.Model model = messages.Model();
|
||||
model.mergeFromBuffer(message);
|
||||
print(model.toProto3Json().toString());
|
||||
onMessageReceived(model);
|
||||
}
|
||||
}, onError: (error, StackTrace trace) {
|
||||
@ -138,23 +180,25 @@ class CIMSocket {
|
||||
Future sendLoginMsg() async {
|
||||
SystemInfo systemInfo = SystemInfo();
|
||||
await systemInfo.init();
|
||||
String deviceName = systemInfo.deviceName;
|
||||
String deviceName = devicename ?? systemInfo.deviceName;
|
||||
// DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
String channelName = systemInfo.deviceName;
|
||||
String systemVersion = systemInfo.version;
|
||||
String deviceId = hex.encode(
|
||||
md5.convert(const Utf8Encoder().convert(systemInfo.deviceId)).bytes);
|
||||
String channelN = channelName ?? systemInfo.deviceName;
|
||||
String systemVersion = osVersion ?? systemInfo.version;
|
||||
String deviceId = deviceid ??
|
||||
hex.encode(md5
|
||||
.convert(const Utf8Encoder().convert(systemInfo.deviceId))
|
||||
.bytes);
|
||||
|
||||
Map<String, String> map = {
|
||||
"uid": uid!, //主id
|
||||
"channel": channelName,
|
||||
"channel": channelN,
|
||||
"appVersion": sOCKETAPPVERSION,
|
||||
"osVersion": systemVersion,
|
||||
"packageName": "cn.asihe.cim",
|
||||
"packageName": packageName ?? "cn.asihe.cim",
|
||||
"deviceId": deviceId,
|
||||
// (await PlatformDeviceId.getDeviceId)!.replaceAll("-", ""), //应用id
|
||||
"deviceName": '$deviceName ${systemInfo.model}',
|
||||
"language": "zh-CN",
|
||||
"deviceName": '$deviceName',
|
||||
"language": language ?? "zh-CN",
|
||||
};
|
||||
int time = DateTime.now().millisecondsSinceEpoch;
|
||||
Int64 timeStamp = Int64.parseInt(time.toString());
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: cim_flutter_websocket_sdk
|
||||
description: A flutter websocket sdk for cim. Cim is a websocket based instant messaging protocol,support websocket protocol and socket protocol.
|
||||
version: 1.0.0
|
||||
version: 1.0.1
|
||||
homepage: http://farsunset.com/
|
||||
|
||||
environment:
|
||||
|
Loading…
x
Reference in New Issue
Block a user