From 1d8bf474f94e0080715d25e698a0494539daa276 Mon Sep 17 00:00:00 2001 From: yangjiejie12308 <38904385+yangjiejie12308@users.noreply.github.com> Date: Wed, 14 Jun 2023 09:36:31 +0800 Subject: [PATCH 01/12] update flutter sdk --- cim-client-sdk/cim-flutter-sdk/.gitignore | 30 ++ cim-client-sdk/cim-flutter-sdk/.metadata | 27 ++ cim-client-sdk/cim-flutter-sdk/CHANGELOG.md | 3 + cim-client-sdk/cim-flutter-sdk/LICENSE | 1 + cim-client-sdk/cim-flutter-sdk/README.md | 18 + .../cim-flutter-sdk/analysis_options.yaml | 4 + .../cim-flutter-sdk/cim-boot-client.dart | 117 ------- .../cim-flutter-sdk/example/.gitignore | 44 +++ .../cim-flutter-sdk/example/README.md | 16 + .../example/analysis_options.yaml | 29 ++ .../cim-flutter-sdk/example/lib/main.dart | 65 ++++ .../cim-flutter-sdk/example/pubspec.lock | 313 ++++++++++++++++++ .../cim-flutter-sdk/example/pubspec.yaml | 83 +++++ .../example/test/widget_test.dart | 27 ++ .../cim-flutter-sdk/lib/CimSocket.dart | 268 +++++++++++++++ .../{protobuf => lib}/Message.pb.dart | 0 .../{protobuf => lib}/Message.pbenum.dart | 0 .../{protobuf => lib}/Message.pbjson.dart | 0 .../{protobuf => lib}/Message.pbserver.dart | 0 .../{protobuf => lib}/Message.proto | 0 .../{protobuf => lib}/ReplyBody.pb.dart | 0 .../{protobuf => lib}/ReplyBody.pbenum.dart | 0 .../{protobuf => lib}/ReplyBody.pbjson.dart | 0 .../{protobuf => lib}/ReplyBody.pbserver.dart | 0 .../{protobuf => lib}/ReplyBody.proto | 0 .../{protobuf => lib}/SentBody.pb.dart | 0 .../{protobuf => lib}/SentBody.pbenum.dart | 0 .../{protobuf => lib}/SentBody.pbjson.dart | 0 .../{protobuf => lib}/SentBody.pbserver.dart | 0 .../{protobuf => lib}/SentBody.proto | 0 .../cim-flutter-sdk/lib/cim_flutter_sdk.dart | 22 ++ .../lib/cim_flutter_sdk_method_channel.dart | 17 + .../cim_flutter_sdk_platform_interface.dart | 29 ++ cim-client-sdk/cim-flutter-sdk/pubspec.yaml | 78 +++++ 34 files changed, 1074 insertions(+), 117 deletions(-) create mode 100644 cim-client-sdk/cim-flutter-sdk/.gitignore create mode 100644 cim-client-sdk/cim-flutter-sdk/.metadata create mode 100644 cim-client-sdk/cim-flutter-sdk/CHANGELOG.md create mode 100644 cim-client-sdk/cim-flutter-sdk/LICENSE create mode 100644 cim-client-sdk/cim-flutter-sdk/README.md create mode 100644 cim-client-sdk/cim-flutter-sdk/analysis_options.yaml delete mode 100644 cim-client-sdk/cim-flutter-sdk/cim-boot-client.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/example/.gitignore create mode 100644 cim-client-sdk/cim-flutter-sdk/example/README.md create mode 100644 cim-client-sdk/cim-flutter-sdk/example/analysis_options.yaml create mode 100644 cim-client-sdk/cim-flutter-sdk/example/lib/main.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/example/pubspec.lock create mode 100644 cim-client-sdk/cim-flutter-sdk/example/pubspec.yaml create mode 100644 cim-client-sdk/cim-flutter-sdk/example/test/widget_test.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/lib/CimSocket.dart rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/Message.pb.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/Message.pbenum.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/Message.pbjson.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/Message.pbserver.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/Message.proto (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/ReplyBody.pb.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/ReplyBody.pbenum.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/ReplyBody.pbjson.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/ReplyBody.pbserver.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/ReplyBody.proto (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/SentBody.pb.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/SentBody.pbenum.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/SentBody.pbjson.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/SentBody.pbserver.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{protobuf => lib}/SentBody.proto (100%) create mode 100644 cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_method_channel.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_platform_interface.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/pubspec.yaml diff --git a/cim-client-sdk/cim-flutter-sdk/.gitignore b/cim-client-sdk/cim-flutter-sdk/.gitignore new file mode 100644 index 0000000..96486fd --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/cim-client-sdk/cim-flutter-sdk/.metadata b/cim-client-sdk/cim-flutter-sdk/.metadata new file mode 100644 index 0000000..7f104ef --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/.metadata @@ -0,0 +1,27 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + channel: stable + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md new file mode 100644 index 0000000..41cc7d8 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/cim-client-sdk/cim-flutter-sdk/LICENSE b/cim-client-sdk/cim-flutter-sdk/LICENSE new file mode 100644 index 0000000..ba75c69 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/README.md new file mode 100644 index 0000000..3ea4eb8 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/README.md @@ -0,0 +1,18 @@ +# cim_flutter_sdk + +A new Flutter plugin project. + +## Getting Started + +This project is a starting point for a Flutter +[plug-in package](https://flutter.dev/developing-packages/), +a specialized package that includes platform-specific implementation code for +Android and/or iOS. + +For help getting started with Flutter development, view the +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. + +The plugin project was generated without specifying the `--platforms` flag, no platforms are currently supported. +To add platforms, run `flutter create -t plugin --platforms .` in this directory. +You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms. diff --git a/cim-client-sdk/cim-flutter-sdk/analysis_options.yaml b/cim-client-sdk/cim-flutter-sdk/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/cim-client-sdk/cim-flutter-sdk/cim-boot-client.dart b/cim-client-sdk/cim-flutter-sdk/cim-boot-client.dart deleted file mode 100644 index 797f28f..0000000 --- a/cim-client-sdk/cim-flutter-sdk/cim-boot-client.dart +++ /dev/null @@ -1,117 +0,0 @@ -import 'dart:io'; -import 'dart:typed_data'; - -import '../protobuf/Message.pb.dart' as Message; -import '../protobuf/ReplyBody.pb.dart' as ReplyBody; -import '../protobuf/SentBody.pb.dart' as SentBody; -import 'package:fixnum/fixnum.dart'; - -late Socket socket; - -const APP_VERSION = "1.0.0"; -const APP_CHANNEL = "web"; -const APP_PACKAGE = "com.farsunset.cim"; -const SERVER_URL = "192.168.10.133"; -const SERVER_PORT = 23456; - -//PONG -const PONG_TYPE = 0; -//发送消息类型 -const Message_TYPE = 2; -//强制下线类型 -const ACTION_999 = 999; -//响应消息类型 -const REPLY_BODY = 4; -//消息发送 -const SEND_BODY = 3; -//PING -const PING_TYPE = 1; - -const DATA_HEADER_LENGTH = 1; - -void connect() async { - print('-------------开始连接----------------'); - Socket.connect(SERVER_URL, SERVER_PORT).then((Socket sock) { - // socket = sock; - sock.listen(dataHandler, - onError: errorHandler, onDone: doneHandler, cancelOnError: false); - socket = sock; - sendLoginMsg(); - }).catchError((e) { - print("Unable to connect: $e"); - }); -} - -void dataHandler(Uint8List data) { - print(data[0]); - int l = (data[1] & 0xff); - int h = (data[2] & 0xff); - int length = (l | h << 8); - if (data[0] == PING_TYPE) { - sendPong(); - } else if (data[0] == REPLY_BODY) { - var message = data.sublist(3, length + 3); - ReplyBody.Model info = new ReplyBody.Model(); - info.mergeFromBuffer(message); - print(info.key); - print(info); - } else if (data[0] == Message_TYPE) { - var message = data.sublist(3, length + 3); - Message.Model model = new Message.Model(); - model.mergeFromBuffer(message); - print(model.action); - print(model); - } -} - -void errorHandler(error, StackTrace trace) { - print(error); -} - -void doneHandler() { - print("-------------连接失败----------------"); -} - -//发送登录消息 -void sendLoginMsg() async { - Map map = { - "uid": "11111111112346121631126311", - "channel": APP_CHANNEL, - "appVersion": APP_VERSION, - "osVersion": "Android 10", - "packageName": APP_PACKAGE, - "deviceId": "121155155a61d6a1s6d1as6d1a6s1da", - "deviceName": "andoirdPhone", - "language": "Zh_cn", - }; - int time = new DateTime.now().millisecondsSinceEpoch; - Int64 timeStamp = Int64.parseInt(time.toString()); - var body = SentBody.Model(data: map); - body.key = "client_bind"; - body.timestamp = timeStamp; - var data = body.writeToBuffer(); - var protobuf = new Uint8List(data.length + 3); - protobuf[0] = 3; - protobuf[1] = (data.length & 0xff); - protobuf[2] = ((data.length >> 8) & 0xff); - protobuf.setRange(3, data.length + 3, data); - socket.add(protobuf); - await socket.flush(); -} - -//发送PONG响应 -void sendPong() async { - var PONG = new Uint8List(7); - var PONG_BODY = new Uint8List(4); - PONG_BODY[0] = 80; - PONG_BODY[1] = 79; - PONG_BODY[2] = 78; - PONG_BODY[3] = 71; - PONG[0] = PONG_TYPE; - PONG[1] = (PONG_BODY.length & 0xff); - PONG[2] = ((PONG_BODY.length >> 8) & 0xff); - PONG.setRange(3, 6, PONG_BODY); - socket.add(PONG); - await socket.flush(); - print("发送Pong"); -} diff --git a/cim-client-sdk/cim-flutter-sdk/example/.gitignore b/cim-client-sdk/cim-flutter-sdk/example/.gitignore new file mode 100644 index 0000000..24476c5 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/cim-client-sdk/cim-flutter-sdk/example/README.md b/cim-client-sdk/cim-flutter-sdk/example/README.md new file mode 100644 index 0000000..cd437a1 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/README.md @@ -0,0 +1,16 @@ +# cim_flutter_sdk_example + +Demonstrates how to use the cim_flutter_sdk plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/cim-client-sdk/cim-flutter-sdk/example/analysis_options.yaml b/cim-client-sdk/cim-flutter-sdk/example/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart b/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart new file mode 100644 index 0000000..86269fe --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart @@ -0,0 +1,65 @@ +import 'package:cim_flutter_sdk/CimSocket.dart'; +import 'package:flutter/material.dart'; +import 'dart:async'; + +import 'package:flutter/services.dart'; +import 'package:cim_flutter_sdk/cim_flutter_sdk.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({super.key}); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + String Message = 'Unknown'; + final _cimFlutterSdkPlugin = CimFlutterSdk(); + + @override + void initState() { + super.initState(); + initCimState(); + } + + // Platform messages are asynchronous, so we initialize in an async method. + Future initCimState() async { + CIMSocket cimSocket; + // Platform messages may fail, so we use a try/catch PlatformException. + // We also handle the message potentially returning null. + try { + cimSocket = await _cimFlutterSdkPlugin.connect( + '127.0.0.1', 23456, 16501516154949); + cimSocket.addListener(() { + print(cimSocket.model!.toProto3Json()); + if (!mounted) return; + + setState(() { + Message = cimSocket.model!.toProto3Json().toString(); + }); + }); + } on PlatformException {} + + // If the widget was removed from the tree while the asynchronous platform + // message was in flight, we want to discard the reply rather than calling + // setState to update our non-existent appearance. + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Message is: $Message\n'), + ), + ), + ); + } +} diff --git a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock new file mode 100644 index 0000000..9e26908 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock @@ -0,0 +1,313 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.10.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.1" + cim_flutter_sdk: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.0.1" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.17.0" + common_utils: + dependency: transitive + description: + name: common_utils + sha256: c26884339b13ff99b0739e56f4b02090c84054ed9dd3a045435cd24e7b99c2c1 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.0.3" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.5" + decimal: + dependency: transitive + description: + name: decimal + sha256: eece91944f523657c75a3a008a90ec7f7eb3986191153a78570c7d0ac8ef3d01 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.3.2" + device_info_plus: + dependency: transitive + description: + name: device_info_plus + sha256: f52ab3b76b36ede4d135aab80194df8925b553686f0fa12226b4e2d658e45903 + url: "https://pub.flutter-io.cn" + source: hosted + version: "8.2.2" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.0.0" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.2" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.flutter-io.cn" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.1" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: + dependency: transitive + description: + name: js + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.5" + lints: + dependency: transitive + description: + name: lints + sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.12.13" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.2.0" + meta: + dependency: transitive + description: + name: meta + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.8.0" + path: + dependency: transitive + description: + name: path + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.8.2" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.4" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "01dd9bd0fa02548bf2ceee13545d4a0ec6046459d847b6b061d8a27237108a08" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.0" + rational: + dependency: transitive + description: + name: rational + sha256: ba58e9e18df9abde280e8b10051e4bce85091e41e8e7e411b6cde2e738d357cf + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.2.2" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.9.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.4.16" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.3.2" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.4" + win32: + dependency: transitive + description: + name: win32 + sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.4" +sdks: + dart: ">=2.19.4 <3.0.0" + flutter: ">=2.11.0" diff --git a/cim-client-sdk/cim-flutter-sdk/example/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/example/pubspec.yaml new file mode 100644 index 0000000..76a4c63 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/pubspec.yaml @@ -0,0 +1,83 @@ +name: cim_flutter_sdk_example +description: Demonstrates how to use the cim_flutter_sdk plugin. +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: '>=2.19.4 <3.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + cim_flutter_sdk: + # When depending on this package from a real application you should use: + # cim_flutter_sdk: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/cim-client-sdk/cim-flutter-sdk/example/test/widget_test.dart b/cim-client-sdk/cim-flutter-sdk/example/test/widget_test.dart new file mode 100644 index 0000000..6221123 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/test/widget_test.dart @@ -0,0 +1,27 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:cim_flutter_sdk_example/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => widget is Text && + widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +} diff --git a/cim-client-sdk/cim-flutter-sdk/lib/CimSocket.dart b/cim-client-sdk/cim-flutter-sdk/lib/CimSocket.dart new file mode 100644 index 0000000..67ec19d --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/lib/CimSocket.dart @@ -0,0 +1,268 @@ +// ignore: file_names +import 'dart:async'; +import 'dart:convert'; +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:common_utils/common_utils.dart'; +import 'package:crypto/crypto.dart'; +import 'package:device_info_plus/device_info_plus.dart'; +import 'package:flutter/material.dart'; + +import './Message.pb.dart' as Message; +import './ReplyBody.pb.dart' as ReplyBody; +import './SentBody.pb.dart' as SentBody; +import 'package:fixnum/fixnum.dart'; +import 'package:convert/convert.dart'; + +//PONG +// ignore: constant_identifier_names +const PONG_TYPE = 0; +//发送消息类型 +// ignore: constant_identifier_names +const Message_TYPE = 2; +//强制下线类型 +// ignore: constant_identifier_names +const ACTION_999 = 999; +//响应消息类型 +// ignore: constant_identifier_names +const REPLY_BODY = 4; +//消息发送 +// ignore: constant_identifier_names +const SEND_BODY = 3; +//PING +// ignore: constant_identifier_names +const PING_TYPE = 1; + +// ignore: constant_identifier_names +const DATA_HEADER_LENGTH = 1; + +const SOCKET_APP_VERSION = '100'; + +class CIMSocket extends ChangeNotifier { + late Socket? socket; + late String? uri; + late int? port; + late int? uid; + late String endCode = "0"; + final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); + late TimerUtil timer = TimerUtil() + ..mTotalTime = 10000 + ..setOnTimerTickCallback((millisUntilFinished) { + connect(); + }); + late bool isConnected = false; + + late Message.Model? model = null; + + Future init(String uri, int port, int uid) async { + this.uri = uri; + this.port = port; + this.uid = uid; + } + + //登录 + Future connect() async { + if (uri == null || port == null || uid == null) { + throw IOException; + } + Socket.connect(uri, port!).then((Socket sock) { + sock.listen((data) async { + int l = (data[1] & 0xff); + int h = (data[2] & 0xff); + int length = (l | h << 8); + if (data[0] == PING_TYPE) { + sendPong(); + } else if (data[0] == REPLY_BODY) { + var message = data.sublist(3, length + 3); + ReplyBody.Model info = ReplyBody.Model(); + info.mergeFromBuffer(message); + } else if (data[0] == Message_TYPE) { + var message = data.sublist(3, length + 3); + Message.Model model = Message.Model(); + model.mergeFromBuffer(message); + switchMessage(model); + } + }, onError: (error, StackTrace trace) { + print('CIMSocket error'); + socket = null; + isConnected = false; + if (!timer.isActive()) { + timer.startTimer(); + } + notifyListeners(); + }, onDone: () { + print('CIMSocket done'); + socket = null; + isConnected = false; + notifyListeners(); + if (endCode != "999") { + if (!timer.isActive()) { + timer.startTimer(); + } + } + }, cancelOnError: true); + socket = sock; + sendLoginMsg(); + }).catchError((e) { + print('CIMSocket catcherror'); + print('Unable to connect: $e'); + socket = null; + isConnected = false; + notifyListeners(); + // Future.delayed(Duration(milliseconds: 3000), () { + // connect(); + // }); + if (!timer.isActive()) { + timer.startTimer(); + } + }); + } + + //登出 + Future disConnect() async { + if (socket != null) { + endCode = '999'; + await socket!.close(); + } + } + + //发送登录消息 + Future sendLoginMsg() async { + SystemInfo systemInfo = SystemInfo(); + await systemInfo.init(); + String 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); + + Map map = { + "uid": uid.toString(), //主id + "channel": channel, + "appVersion": SOCKET_APP_VERSION, + "osVersion": systemVersion, + "packageName": "cn.asihe.cim", + "deviceId": deviceId, + // (await PlatformDeviceId.getDeviceId)!.replaceAll("-", ""), //应用id + "deviceName": '$deviceName ${systemInfo.model}', + "language": "zh-CN", + }; + int time = DateTime.now().millisecondsSinceEpoch; + Int64 timeStamp = Int64.parseInt(time.toString()); + var body = SentBody.Model(data: map); + body.key = "client_bind"; + body.timestamp = timeStamp; + var data = body.writeToBuffer(); + var protobuf = Uint8List(data.length + 3); + protobuf[0] = 3; + protobuf[1] = (data.length & 0xff); + protobuf[2] = ((data.length >> 8) & 0xff); + protobuf.setRange(3, data.length + 3, data); + socket!.add(protobuf); + await socket!.flush(); + print('CIMSocket login finished'); + isConnected = true; + if (timer.isActive()) { + timer.cancel(); + } + notifyListeners(); + } + + /// 发送群组聊天 tag + Future sendTag(String tag) async { + Map map1 = {"tag": tag}; + int time = DateTime.now().millisecondsSinceEpoch; + Int64 timeStamp = Int64.parseInt(time.toString()); + var body = SentBody.Model(data: map1); + body.key = "client_set_tag"; + body.timestamp = timeStamp; + var data = body.writeToBuffer(); + var protobuf = Uint8List(data.length + 3); + protobuf[0] = 3; + protobuf[1] = (data.length & 0xff); + protobuf[2] = ((data.length >> 8) & 0xff); + protobuf.setRange(3, data.length + 3, data); + socket!.add(protobuf); + await socket!.flush(); + print('CIMSocket bind chattingTag Success!'); + return 2; + } + +//发送PONG响应 + Future sendPong() async { + var PONG = Uint8List(7); + var PONG_BODY = Uint8List(4); + PONG_BODY[0] = 80; + PONG_BODY[1] = 79; + PONG_BODY[2] = 78; + PONG_BODY[3] = 71; + PONG[0] = PONG_TYPE; + PONG[1] = (PONG_BODY.length & 0xff); + PONG[2] = ((PONG_BODY.length >> 8) & 0xff); + PONG.setRange(3, 6, PONG_BODY); + socket!.add(PONG); + await socket!.flush(); + isConnected = true; + if (timer.isActive()) { + timer.cancel(); + } + notifyListeners(); + } + + ///消息分发器 + Future switchMessage(Message.Model model, {bool isHistory = false}) async { + print(model.toProto3Json()); + model = model; + notifyListeners(); + } +} + +class SystemInfo { + String deviceName = 'cim_entity'; + String version = '0.0.1'; + String deviceId = 'CIM Entity'; + String model = "10"; + final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); + + Future init() async { + if (Platform.isAndroid) { + // Android相关代码 + var value = await deviceInfoPlugin.androidInfo; + deviceName = 'android'; + version = value.version.release; + deviceId = value.id; + model = value.model; + } else if (Platform.isIOS) { + // iOS相关代码 + var value = await deviceInfoPlugin.iosInfo; + deviceName = 'ios'; + version = value.systemVersion!; + deviceId = value.identifierForVendor!; + model = value.model!; + } else if (Platform.isMacOS) { + // MacOS相关代码 + var value = await deviceInfoPlugin.macOsInfo; + + deviceName = 'macos'; + version = value.kernelVersion; + deviceId = value.model; + model = value.model; + } else if (Platform.isWindows) { + // Windows相关代码 + var value = await deviceInfoPlugin.windowsInfo; + deviceName = 'windows'; + version = value.displayVersion; + deviceId = value.deviceId; + model = value.majorVersion.toString(); + } else if (Platform.isLinux) { + // Linux相关代码 + var value = await deviceInfoPlugin.linuxInfo; + deviceName = 'linux'; + version = value.version!; + deviceId = value.id; + model = value.version!; + } + } +} diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/Message.pb.dart b/cim-client-sdk/cim-flutter-sdk/lib/Message.pb.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/Message.pb.dart rename to cim-client-sdk/cim-flutter-sdk/lib/Message.pb.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/Message.pbenum.dart b/cim-client-sdk/cim-flutter-sdk/lib/Message.pbenum.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/Message.pbenum.dart rename to cim-client-sdk/cim-flutter-sdk/lib/Message.pbenum.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/Message.pbjson.dart b/cim-client-sdk/cim-flutter-sdk/lib/Message.pbjson.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/Message.pbjson.dart rename to cim-client-sdk/cim-flutter-sdk/lib/Message.pbjson.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/Message.pbserver.dart b/cim-client-sdk/cim-flutter-sdk/lib/Message.pbserver.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/Message.pbserver.dart rename to cim-client-sdk/cim-flutter-sdk/lib/Message.pbserver.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/Message.proto b/cim-client-sdk/cim-flutter-sdk/lib/Message.proto similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/Message.proto rename to cim-client-sdk/cim-flutter-sdk/lib/Message.proto diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.pb.dart b/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pb.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.pb.dart rename to cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pb.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.pbenum.dart b/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbenum.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.pbenum.dart rename to cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbenum.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.pbjson.dart b/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbjson.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.pbjson.dart rename to cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbjson.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.pbserver.dart b/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbserver.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.pbserver.dart rename to cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbserver.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.proto b/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.proto similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/ReplyBody.proto rename to cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.proto diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.pb.dart b/cim-client-sdk/cim-flutter-sdk/lib/SentBody.pb.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.pb.dart rename to cim-client-sdk/cim-flutter-sdk/lib/SentBody.pb.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.pbenum.dart b/cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbenum.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.pbenum.dart rename to cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbenum.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.pbjson.dart b/cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbjson.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.pbjson.dart rename to cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbjson.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.pbserver.dart b/cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbserver.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.pbserver.dart rename to cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbserver.dart diff --git a/cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.proto b/cim-client-sdk/cim-flutter-sdk/lib/SentBody.proto similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/protobuf/SentBody.proto rename to cim-client-sdk/cim-flutter-sdk/lib/SentBody.proto diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart new file mode 100644 index 0000000..d2b70c2 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart @@ -0,0 +1,22 @@ +// You have generated a new plugin project without specifying the `--platforms` +// flag. A plugin project with no platform support was generated. To add a +// platform, run `flutter create -t plugin --platforms .` under the +// same directory. You can also find a detailed instruction on how to add +// platforms in the `pubspec.yaml` at +// https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms. + +import 'CimSocket.dart'; +import 'cim_flutter_sdk_platform_interface.dart'; + +class CimFlutterSdk { + final CIMSocket cimSocket = CIMSocket(); + Future connect(String uri, int port, int uid) async { + cimSocket.init(uri, port, uid); + cimSocket.connect(); + return cimSocket; + } + + Future disconnect() async { + cimSocket.disConnect(); + } +} diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_method_channel.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_method_channel.dart new file mode 100644 index 0000000..f2be325 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_method_channel.dart @@ -0,0 +1,17 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; + +import 'cim_flutter_sdk_platform_interface.dart'; + +/// An implementation of [CimFlutterSdkPlatform] that uses method channels. +class MethodChannelCimFlutterSdk extends CimFlutterSdkPlatform { + /// The method channel used to interact with the native platform. + @visibleForTesting + final methodChannel = const MethodChannel('cim_flutter_sdk'); + + @override + Future getPlatformVersion() async { + final version = await methodChannel.invokeMethod('getPlatformVersion'); + return version; + } +} diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_platform_interface.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_platform_interface.dart new file mode 100644 index 0000000..46d6d9c --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_platform_interface.dart @@ -0,0 +1,29 @@ +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + +import 'cim_flutter_sdk_method_channel.dart'; + +abstract class CimFlutterSdkPlatform extends PlatformInterface { + /// Constructs a CimFlutterSdkPlatform. + CimFlutterSdkPlatform() : super(token: _token); + + static final Object _token = Object(); + + static CimFlutterSdkPlatform _instance = MethodChannelCimFlutterSdk(); + + /// The default instance of [CimFlutterSdkPlatform] to use. + /// + /// Defaults to [MethodChannelCimFlutterSdk]. + static CimFlutterSdkPlatform get instance => _instance; + + /// Platform-specific implementations should set this with their own + /// platform-specific class that extends [CimFlutterSdkPlatform] when + /// they register themselves. + static set instance(CimFlutterSdkPlatform instance) { + PlatformInterface.verifyToken(instance, _token); + _instance = instance; + } + + Future getPlatformVersion() { + throw UnimplementedError('platformVersion() has not been implemented.'); + } +} diff --git a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml new file mode 100644 index 0000000..fb646ed --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml @@ -0,0 +1,78 @@ +name: cim_flutter_sdk +description: A new Flutter plugin project. +version: 0.0.1 +homepage: + +environment: + sdk: '>=2.19.4 <3.0.0' + flutter: '>=2.5.0' + +dependencies: + flutter: + sdk: flutter + plugin_platform_interface: ^2.0.2 + protobuf: ^2.0.1 # Google protobuf 序列化 + device_info_plus: ^8.2.2 + common_utils: ^2.1.0 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + # This section identifies this Flutter project as a plugin project. + # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) + # which should be registered in the plugin registry. This is required for + # using method channels. + # The Android 'package' specifies package in which the registered class is. + # This is required for using method channels on Android. + # The 'ffiPlugin' specifies that native code should be built and bundled. + # This is required for using `dart:ffi`. + # All these are used by the tooling to maintain consistency when + # adding or updating assets for this project. + plugin: + platforms: + # This plugin project was generated without specifying any + # platforms with the `--platform` argument. If you see the `some_platform` map below, remove it and + # then add platforms following the instruction here: + # https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms + # ------------------- + some_platform: + pluginClass: somePluginClass + # ------------------- + + # To add assets to your plugin package, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + # + # For details regarding assets in packages, see + # https://flutter.dev/assets-and-images/#from-packages + # + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # To add custom fonts to your plugin package, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts in packages, see + # https://flutter.dev/custom-fonts/#from-packages From c5947f718ffe8fd9cc18b18fffb345e6c19eebf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=9D=B0?= <5301327+smebclub@user.noreply.gitee.com> Date: Tue, 4 Jul 2023 06:15:21 +0000 Subject: [PATCH 02/12] update cim-client-sdk/cim-flutter-sdk/README.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨杰 <5301327+smebclub@user.noreply.gitee.com> --- cim-client-sdk/cim-flutter-sdk/README.md | 47 ++++++++++++++++++------ 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/README.md index 3ea4eb8..cb2bc77 100644 --- a/cim-client-sdk/cim-flutter-sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/README.md @@ -1,18 +1,41 @@ # cim_flutter_sdk -A new Flutter plugin project. +开源通讯库 [CIM](https://gitee.com/farsunset/cim) 的 flutter版本SDK -## Getting Started +## 如何使用 -This project is a starting point for a Flutter -[plug-in package](https://flutter.dev/developing-packages/), -a specialized package that includes platform-specific implementation code for -Android and/or iOS. -For help getting started with Flutter development, view the -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. -The plugin project was generated without specifying the `--platforms` flag, no platforms are currently supported. -To add platforms, run `flutter create -t plugin --platforms .` in this directory. -You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms. +``` +import 'package:cim_flutter_sdk/cim_flutter_sdk.dart'; +... + +CIMSocket cimSocket; + +String Message = 'Unknown'; + +cimSocket = await _cimFlutterSdkPlugin.connect( + '127.0.0.1', 23456, 16501516154949); + cimSocket.addListener(() { + print(cimSocket.model!.toProto3Json()); + if (!mounted) return; + + setState(() { + Message = cimSocket.model!.toProto3Json().toString(); + }); + }); + +... + + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Message is: $Message\n'), + ), + ), + ); + +``` From 721839d981b9bb29488896915cf9fea1566fcb96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=9D=B0?= <5301327+smebclub@user.noreply.gitee.com> Date: Tue, 4 Jul 2023 06:25:18 +0000 Subject: [PATCH 03/12] update cim-client-sdk/cim-flutter-sdk/README.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨杰 <5301327+smebclub@user.noreply.gitee.com> --- cim-client-sdk/cim-flutter-sdk/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/README.md index cb2bc77..8b902e1 100644 --- a/cim-client-sdk/cim-flutter-sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/README.md @@ -2,10 +2,15 @@ 开源通讯库 [CIM](https://gitee.com/farsunset/cim) 的 flutter版本SDK +## 如何在自己的项目中引用SDK + +在 pubspec.yaml 引入 + +dependencies: + cim_flutter_sdk:^1.0.0 + ## 如何使用 - - ``` import 'package:cim_flutter_sdk/cim_flutter_sdk.dart'; ... From c55c3d5012edc3ddc61568d9ab0ee0650513d31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=9D=B0?= <5301327+smebclub@user.noreply.gitee.com> Date: Tue, 4 Jul 2023 06:25:46 +0000 Subject: [PATCH 04/12] update cim-client-sdk/cim-flutter-sdk/README.md. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 杨杰 <5301327+smebclub@user.noreply.gitee.com> --- cim-client-sdk/cim-flutter-sdk/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/README.md index 8b902e1..359a8bd 100644 --- a/cim-client-sdk/cim-flutter-sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/README.md @@ -6,8 +6,12 @@ 在 pubspec.yaml 引入 + +``` dependencies: cim_flutter_sdk:^1.0.0 +``` + ## 如何使用 From c4b30acef3f9ee2e5c2002236ecffe2d1e7c4db9 Mon Sep 17 00:00:00 2001 From: yangjiejie12308 <38904385+yangjiejie12308@users.noreply.github.com> Date: Tue, 4 Jul 2023 15:58:32 +0800 Subject: [PATCH 05/12] flutter public to pub.dev --- .../cim-flutter-sdk/.flutter-plugins | 2 + .../.flutter-plugins-dependencies | 1 + cim-client-sdk/cim-flutter-sdk/CHANGELOG.md | 4 +- cim-client-sdk/cim-flutter-sdk/LICENSE | 26 +- cim-client-sdk/cim-flutter-sdk/README.md | 54 +++- .../cim-flutter-sdk/example/.metadata | 30 ++ .../cim-flutter-sdk/example/lib/main.dart | 15 +- .../cim-flutter-sdk/example/pubspec.lock | 2 +- .../example/windows/.gitignore | 17 ++ .../example/windows/CMakeLists.txt | 101 ++++++ .../example/windows/flutter/CMakeLists.txt | 104 +++++++ .../flutter/generated_plugin_registrant.cc | 11 + .../flutter/generated_plugin_registrant.h | 15 + .../windows/flutter/generated_plugins.cmake | 23 ++ .../example/windows/runner/CMakeLists.txt | 40 +++ .../example/windows/runner/Runner.rc | 121 ++++++++ .../example/windows/runner/flutter_window.cpp | 66 ++++ .../example/windows/runner/flutter_window.h | 33 ++ .../example/windows/runner/main.cpp | 43 +++ .../example/windows/runner/resource.h | 16 + .../windows/runner/resources/app_icon.ico | Bin 0 -> 33772 bytes .../windows/runner/runner.exe.manifest | 20 ++ .../example/windows/runner/utils.cpp | 64 ++++ .../example/windows/runner/utils.h | 19 ++ .../example/windows/runner/win32_window.cpp | 288 ++++++++++++++++++ .../example/windows/runner/win32_window.h | 102 +++++++ .../cim-flutter-sdk/lib/cim_flutter_sdk.dart | 3 +- .../lib/{CimSocket.dart => cim_socket.dart} | 76 +++-- cim-client-sdk/cim-flutter-sdk/pubspec.yaml | 111 +++---- 29 files changed, 1283 insertions(+), 124 deletions(-) create mode 100644 cim-client-sdk/cim-flutter-sdk/.flutter-plugins create mode 100644 cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies create mode 100644 cim-client-sdk/cim-flutter-sdk/example/.metadata create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/.gitignore create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/CMakeLists.txt create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/flutter/CMakeLists.txt create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.cc create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.h create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugins.cmake create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/CMakeLists.txt create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/Runner.rc create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.cpp create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.h create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/main.cpp create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/resource.h create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/resources/app_icon.ico create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/runner.exe.manifest create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.cpp create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.h create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.cpp create mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.h rename cim-client-sdk/cim-flutter-sdk/lib/{CimSocket.dart => cim_socket.dart} (82%) diff --git a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins new file mode 100644 index 0000000..622aef1 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins @@ -0,0 +1,2 @@ +# This is a generated file; do not edit or check into version control. +device_info_plus=C:\\Users\\smeb\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\device_info_plus-8.2.2\\ diff --git a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies new file mode 100644 index 0000000..c214ef8 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies @@ -0,0 +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.flutter-io.cn\\\\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.flutter-io.cn\\\\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.flutter-io.cn\\\\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.flutter-io.cn\\\\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.flutter-io.cn\\\\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.flutter-io.cn\\\\device_info_plus-8.2.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]}],"date_created":"2023-07-04 15:53:37.990976","version":"3.7.7"} \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md index 41cc7d8..6ce5242 100644 --- a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md +++ b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md @@ -1,3 +1,3 @@ -## 0.0.1 +## 1.0.1 -* TODO: Describe initial release. +* 支持所有平台 diff --git a/cim-client-sdk/cim-flutter-sdk/LICENSE b/cim-client-sdk/cim-flutter-sdk/LICENSE index ba75c69..c822d2b 100644 --- a/cim-client-sdk/cim-flutter-sdk/LICENSE +++ b/cim-client-sdk/cim-flutter-sdk/LICENSE @@ -1 +1,25 @@ -TODO: Add your license here. +Copyright 2022 The SDK Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/README.md index 3ea4eb8..6aa9853 100644 --- a/cim-client-sdk/cim-flutter-sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/README.md @@ -1,18 +1,48 @@ # cim_flutter_sdk -A new Flutter plugin project. +开源通讯库 [CIM](https://gitee.com/farsunset/cim) 的 flutter版本SDK -## Getting Started +## 如何在自己的项目中引用SDK -This project is a starting point for a Flutter -[plug-in package](https://flutter.dev/developing-packages/), -a specialized package that includes platform-specific implementation code for -Android and/or iOS. +在 pubspec.yaml 引入 -For help getting started with Flutter development, view the -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. -The plugin project was generated without specifying the `--platforms` flag, no platforms are currently supported. -To add platforms, run `flutter create -t plugin --platforms .` in this directory. -You can also find a detailed instruction on how to add platforms in the `pubspec.yaml` at https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms. +``` +dependencies: + cim_flutter_sdk:^1.0.1 +``` + + +## 如何使用 + +``` +import 'package:cim_flutter_sdk/cim_socket.dart'; +... + +final CIMSocket cimSocket = CIMSocket(); + +String Message = 'Unknown'; + + cimSocket.init('127.0.0.1', 34567, 16501516154949); + cimSocket.connect(); + cimSocket.addListener(() { + if (cimSocket.model == null) return; + setState(() { + Message = cimSocket.model!.toProto3Json().toString(); + }); + }); + +... + + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Plugin example app'), + ), + body: Center( + child: Text('Message is: $Message\n'), + ), + ), + ); + +``` diff --git a/cim-client-sdk/cim-flutter-sdk/example/.metadata b/cim-client-sdk/cim-flutter-sdk/example/.metadata new file mode 100644 index 0000000..b1fefbe --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + - platform: windows + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart b/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart index 86269fe..cd8bb01 100644 --- a/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart +++ b/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart @@ -1,9 +1,8 @@ -import 'package:cim_flutter_sdk/CimSocket.dart'; +import 'package:cim_flutter_sdk/cim_socket.dart'; import 'package:flutter/material.dart'; import 'dart:async'; import 'package:flutter/services.dart'; -import 'package:cim_flutter_sdk/cim_flutter_sdk.dart'; void main() { runApp(const MyApp()); @@ -18,26 +17,22 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { String Message = 'Unknown'; - final _cimFlutterSdkPlugin = CimFlutterSdk(); - @override void initState() { super.initState(); initCimState(); } + final CIMSocket cimSocket = CIMSocket(); // Platform messages are asynchronous, so we initialize in an async method. Future initCimState() async { - CIMSocket cimSocket; // Platform messages may fail, so we use a try/catch PlatformException. // We also handle the message potentially returning null. try { - cimSocket = await _cimFlutterSdkPlugin.connect( - '127.0.0.1', 23456, 16501516154949); + cimSocket.init('api.hoxin.farsunset.com', 34567, 16501516154949); + cimSocket.connect(); cimSocket.addListener(() { - print(cimSocket.model!.toProto3Json()); - if (!mounted) return; - + if (cimSocket.model == null) return; setState(() { Message = cimSocket.model!.toProto3Json().toString(); }); diff --git a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock index 9e26908..13b05ea 100644 --- a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock +++ b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock @@ -31,7 +31,7 @@ packages: path: ".." relative: true source: path - version: "0.0.1" + version: "1.0.1" clock: dependency: transitive description: diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/.gitignore b/cim-client-sdk/cim-flutter-sdk/example/windows/.gitignore new file mode 100644 index 0000000..d492d0d --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/CMakeLists.txt b/cim-client-sdk/cim-flutter-sdk/example/windows/CMakeLists.txt new file mode 100644 index 0000000..c027074 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/CMakeLists.txt @@ -0,0 +1,101 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(example LANGUAGES CXX) + +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. +set(BINARY_NAME "example") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") +set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") +set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") +set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. +function(APPLY_STANDARD_SETTINGS TARGET) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# Application build; see runner/CMakeLists.txt. +add_subdirectory("runner") + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() + +# Fully re-copy the assets directory on each build to avoid having stale files +# from a previous install. +set(FLUTTER_ASSET_DIR_NAME "flutter_assets") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/CMakeLists.txt b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..930d207 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/CMakeLists.txt @@ -0,0 +1,104 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. +set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") + +# === Flutter Library === +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + windows-x64 $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.cc b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..8b6d468 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.h b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugins.cmake b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..b93c4c3 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/CMakeLists.txt b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..394917c --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/Runner.rc b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/Runner.rc new file mode 100644 index 0000000..aecaa2b --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "example" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "example" "\0" + VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "example.exe" "\0" + VALUE "ProductName", "example" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.cpp b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..b25e363 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.cpp @@ -0,0 +1,66 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.h b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.h new file mode 100644 index 0000000..6da0652 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/main.cpp b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/main.cpp new file mode 100644 index 0000000..a61bf80 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"example", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resource.h b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resource.h new file mode 100644 index 0000000..66a65d1 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resources/app_icon.ico b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000000000000000000000000000000000000..c04e20caf6370ebb9253ad831cc31de4a9c965f6 GIT binary patch literal 33772 zcmeHQc|26z|35SKE&G-*mXah&B~fFkXr)DEO&hIfqby^T&>|8^_Ub8Vp#`BLl3lbZ zvPO!8k!2X>cg~Elr=IVxo~J*a`+9wR=A83c-k-DFd(XM&UI1VKCqM@V;DDtJ09WB} zRaHKiW(GT00brH|0EeTeKVbpbGZg?nK6-j827q-+NFM34gXjqWxJ*a#{b_apGN<-L_m3#8Z26atkEn& ze87Bvv^6vVmM+p+cQ~{u%=NJF>#(d;8{7Q{^rWKWNtf14H}>#&y7$lqmY6xmZryI& z($uy?c5-+cPnt2%)R&(KIWEXww>Cnz{OUpT>W$CbO$h1= z#4BPMkFG1Y)x}Ui+WXr?Z!w!t_hjRq8qTaWpu}FH{MsHlU{>;08goVLm{V<&`itk~ zE_Ys=D(hjiy+5=?=$HGii=Y5)jMe9|wWoD_K07(}edAxh`~LBorOJ!Cf@f{_gNCC| z%{*04ViE!#>@hc1t5bb+NO>ncf@@Dv01K!NxH$3Eg1%)|wLyMDF8^d44lV!_Sr}iEWefOaL z8f?ud3Q%Sen39u|%00W<#!E=-RpGa+H8}{ulxVl4mwpjaU+%2pzmi{3HM)%8vb*~-M9rPUAfGCSos8G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?NRg2&G!AZqnmE64eh^Anss3i!{}%6@Et+4rr!=}!SBF8eZ2*J3ujCWbl;3; z48H~goPSv(8X61fKKdpP!Z7$88NL^Z?j`!^*I?-P4X^pMxyWz~@$(UeAcTSDd(`vO z{~rc;9|GfMJcApU3k}22a!&)k4{CU!e_ny^Y3cO;tOvOMKEyWz!vG(Kp*;hB?d|R3`2X~=5a6#^o5@qn?J-bI8Ppip{-yG z!k|VcGsq!jF~}7DMr49Wap-s&>o=U^T0!Lcy}!(bhtYsPQy z4|EJe{12QL#=c(suQ89Mhw9<`bui%nx7Nep`C&*M3~vMEACmcRYYRGtANq$F%zh&V zc)cEVeHz*Z1N)L7k-(k3np#{GcDh2Q@ya0YHl*n7fl*ZPAsbU-a94MYYtA#&!c`xGIaV;yzsmrjfieTEtqB_WgZp2*NplHx=$O{M~2#i_vJ{ps-NgK zQsxKK_CBM2PP_je+Xft`(vYfXXgIUr{=PA=7a8`2EHk)Ym2QKIforz# tySWtj{oF3N9@_;i*Fv5S)9x^z=nlWP>jpp-9)52ZmLVA=i*%6g{{fxOO~wEK literal 0 HcmV?d00001 diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/runner.exe.manifest b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..a42ea76 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.cpp b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.cpp new file mode 100644 index 0000000..f5bf9fa --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.cpp @@ -0,0 +1,64 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr); + std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, utf8_string.data(), + target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.h b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.h new file mode 100644 index 0000000..3879d54 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.cpp b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.cpp new file mode 100644 index 0000000..041a385 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.h b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.h new file mode 100644 index 0000000..c86632d --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // OS callback called by message pump. Handles the WM_NCCREATE message which + // is passed when the non-client area is being created and enables automatic + // non-client DPI scaling so that the non-client area automatically + // responsponds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart index d2b70c2..9c9ccfd 100644 --- a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart +++ b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart @@ -5,8 +5,7 @@ // platforms in the `pubspec.yaml` at // https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms. -import 'CimSocket.dart'; -import 'cim_flutter_sdk_platform_interface.dart'; +import 'cim_socket.dart'; class CimFlutterSdk { final CIMSocket cimSocket = CIMSocket(); diff --git a/cim-client-sdk/cim-flutter-sdk/lib/CimSocket.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart similarity index 82% rename from cim-client-sdk/cim-flutter-sdk/lib/CimSocket.dart rename to cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart index 67ec19d..ef418ae 100644 --- a/cim-client-sdk/cim-flutter-sdk/lib/CimSocket.dart +++ b/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart @@ -1,4 +1,3 @@ -// ignore: file_names import 'dart:async'; import 'dart:convert'; import 'dart:io'; @@ -9,9 +8,9 @@ import 'package:crypto/crypto.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/material.dart'; -import './Message.pb.dart' as Message; -import './ReplyBody.pb.dart' as ReplyBody; -import './SentBody.pb.dart' as SentBody; +import './Message.pb.dart' as messages; +import './ReplyBody.pb.dart' as replybody; +import './SentBody.pb.dart' as sentbody; import 'package:fixnum/fixnum.dart'; import 'package:convert/convert.dart'; @@ -37,7 +36,7 @@ const PING_TYPE = 1; // ignore: constant_identifier_names const DATA_HEADER_LENGTH = 1; -const SOCKET_APP_VERSION = '100'; +const sOCKETAPPVERSION = '100'; class CIMSocket extends ChangeNotifier { late Socket? socket; @@ -49,11 +48,15 @@ class CIMSocket extends ChangeNotifier { late TimerUtil timer = TimerUtil() ..mTotalTime = 10000 ..setOnTimerTickCallback((millisUntilFinished) { - connect(); + if (millisUntilFinished == 0 && uid != null) { + connect(); + } }); late bool isConnected = false; - late Message.Model? model = null; + late messages.Model? _model = null; + + messages.Model? get model => _model; Future init(String uri, int port, int uid) async { this.uri = uri; @@ -75,47 +78,39 @@ class CIMSocket extends ChangeNotifier { sendPong(); } else if (data[0] == REPLY_BODY) { var message = data.sublist(3, length + 3); - ReplyBody.Model info = ReplyBody.Model(); + replybody.Model info = replybody.Model(); info.mergeFromBuffer(message); } else if (data[0] == Message_TYPE) { var message = data.sublist(3, length + 3); - Message.Model model = Message.Model(); + messages.Model model = messages.Model(); model.mergeFromBuffer(message); switchMessage(model); } }, onError: (error, StackTrace trace) { - print('CIMSocket error'); socket = null; isConnected = false; if (!timer.isActive()) { - timer.startTimer(); + timer.setTotalTime(12000); + timer.startCountDown(); } notifyListeners(); }, onDone: () { - print('CIMSocket done'); socket = null; isConnected = false; notifyListeners(); if (endCode != "999") { - if (!timer.isActive()) { - timer.startTimer(); - } + timer.setTotalTime(12000); + timer.startCountDown(); } }, cancelOnError: true); socket = sock; sendLoginMsg(); }).catchError((e) { - print('CIMSocket catcherror'); - print('Unable to connect: $e'); socket = null; isConnected = false; notifyListeners(); - // Future.delayed(Duration(milliseconds: 3000), () { - // connect(); - // }); - if (!timer.isActive()) { - timer.startTimer(); - } + timer.setTotalTime(12000); + timer.startCountDown(); }); } @@ -141,7 +136,7 @@ class CIMSocket extends ChangeNotifier { Map map = { "uid": uid.toString(), //主id "channel": channel, - "appVersion": SOCKET_APP_VERSION, + "appVersion": sOCKETAPPVERSION, "osVersion": systemVersion, "packageName": "cn.asihe.cim", "deviceId": deviceId, @@ -151,7 +146,7 @@ class CIMSocket extends ChangeNotifier { }; int time = DateTime.now().millisecondsSinceEpoch; Int64 timeStamp = Int64.parseInt(time.toString()); - var body = SentBody.Model(data: map); + var body = sentbody.Model(data: map); body.key = "client_bind"; body.timestamp = timeStamp; var data = body.writeToBuffer(); @@ -162,7 +157,6 @@ class CIMSocket extends ChangeNotifier { protobuf.setRange(3, data.length + 3, data); socket!.add(protobuf); await socket!.flush(); - print('CIMSocket login finished'); isConnected = true; if (timer.isActive()) { timer.cancel(); @@ -175,7 +169,7 @@ class CIMSocket extends ChangeNotifier { Map map1 = {"tag": tag}; int time = DateTime.now().millisecondsSinceEpoch; Int64 timeStamp = Int64.parseInt(time.toString()); - var body = SentBody.Model(data: map1); + var body = sentbody.Model(data: map1); body.key = "client_set_tag"; body.timestamp = timeStamp; var data = body.writeToBuffer(); @@ -186,23 +180,22 @@ class CIMSocket extends ChangeNotifier { protobuf.setRange(3, data.length + 3, data); socket!.add(protobuf); await socket!.flush(); - print('CIMSocket bind chattingTag Success!'); return 2; } //发送PONG响应 Future sendPong() async { - var PONG = Uint8List(7); - var PONG_BODY = Uint8List(4); - PONG_BODY[0] = 80; - PONG_BODY[1] = 79; - PONG_BODY[2] = 78; - PONG_BODY[3] = 71; - PONG[0] = PONG_TYPE; - PONG[1] = (PONG_BODY.length & 0xff); - PONG[2] = ((PONG_BODY.length >> 8) & 0xff); - PONG.setRange(3, 6, PONG_BODY); - socket!.add(PONG); + var pONG = Uint8List(7); + var pONGBODY = Uint8List(4); + pONGBODY[0] = 80; + pONGBODY[1] = 79; + pONGBODY[2] = 78; + pONGBODY[3] = 71; + pONG[0] = PONG_TYPE; + pONG[1] = (pONGBODY.length & 0xff); + pONG[2] = ((pONGBODY.length >> 8) & 0xff); + pONG.setRange(3, 6, pONGBODY); + socket!.add(pONG); await socket!.flush(); isConnected = true; if (timer.isActive()) { @@ -212,9 +205,8 @@ class CIMSocket extends ChangeNotifier { } ///消息分发器 - Future switchMessage(Message.Model model, {bool isHistory = false}) async { - print(model.toProto3Json()); - model = model; + Future switchMessage(messages.Model model) async { + _model = model; notifyListeners(); } } diff --git a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml index fb646ed..36bde2f 100644 --- a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml +++ b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml @@ -1,7 +1,8 @@ name: cim_flutter_sdk -description: A new Flutter plugin project. -version: 0.0.1 -homepage: +description: a flutter sdk for cim. +repository: https://gitee.com/farsunset/cim +version: 1.0.1 +homepage: http://farsunset.com/ environment: sdk: '>=2.19.4 <3.0.0' @@ -14,65 +15,67 @@ dependencies: protobuf: ^2.0.1 # Google protobuf 序列化 device_info_plus: ^8.2.2 common_utils: ^2.1.0 + crypto: ^3.0.3 + convert: ^3.1.1 + fixnum: ^1.1.0 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 - # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter packages. -flutter: - # This section identifies this Flutter project as a plugin project. - # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) - # which should be registered in the plugin registry. This is required for - # using method channels. - # The Android 'package' specifies package in which the registered class is. - # This is required for using method channels on Android. - # The 'ffiPlugin' specifies that native code should be built and bundled. - # This is required for using `dart:ffi`. - # All these are used by the tooling to maintain consistency when - # adding or updating assets for this project. - plugin: - platforms: - # This plugin project was generated without specifying any - # platforms with the `--platform` argument. If you see the `some_platform` map below, remove it and - # then add platforms following the instruction here: - # https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms - # ------------------- - some_platform: - pluginClass: somePluginClass - # ------------------- +#flutter: +# This section identifies this Flutter project as a plugin project. +# The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) +# which should be registered in the plugin registry. This is required for +# using method channels. +# The Android 'package' specifies package in which the registered class is. +# This is required for using method channels on Android. +# The 'ffiPlugin' specifies that native code should be built and bundled. +# This is required for using `dart:ffi`. +# All these are used by the tooling to maintain consistency when +# adding or updating assets for this project. +#plugin: +# platforms: +# This plugin project was generated without specifying any +# platforms with the `--platform` argument. If you see the `some_platform` map below, remove it and +# then add platforms following the instruction here: +# https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms +# ------------------- +# some_platform: +# pluginClass: somePluginClass +# ------------------- - # To add assets to your plugin package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware +# To add assets to your plugin package, add an assets section, like this: +# assets: +# - images/a_dot_burr.jpeg +# - images/a_dot_ham.jpeg +# +# For details regarding assets in packages, see +# https://flutter.dev/assets-and-images/#from-packages +# +# An image asset can refer to one or more resolution-specific "variants", see +# https://flutter.dev/assets-and-images/#resolution-aware - # To add custom fonts to your plugin package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages +# To add custom fonts to your plugin package, add a fonts section here, +# in this "flutter" section. Each entry in this list should have a +# "family" key with the font family name, and a "fonts" key with a +# list giving the asset and other descriptors for the font. For +# example: +# fonts: +# - family: Schyler +# fonts: +# - asset: fonts/Schyler-Regular.ttf +# - asset: fonts/Schyler-Italic.ttf +# style: italic +# - family: Trajan Pro +# fonts: +# - asset: fonts/TrajanPro.ttf +# - asset: fonts/TrajanPro_Bold.ttf +# weight: 700 +# +# For details regarding fonts in packages, see +# https://flutter.dev/custom-fonts/#from-packages From 457eb21769239af20ae129e794161809b41ace0f Mon Sep 17 00:00:00 2001 From: yangjiejie12308 <38904385+yangjiejie12308@users.noreply.github.com> Date: Tue, 4 Jul 2023 16:01:30 +0800 Subject: [PATCH 06/12] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/windows/.gitignore | 17 -- .../example/windows/CMakeLists.txt | 101 ------ .../example/windows/flutter/CMakeLists.txt | 104 ------- .../flutter/generated_plugin_registrant.cc | 11 - .../flutter/generated_plugin_registrant.h | 15 - .../windows/flutter/generated_plugins.cmake | 23 -- .../example/windows/runner/CMakeLists.txt | 40 --- .../example/windows/runner/Runner.rc | 121 -------- .../example/windows/runner/flutter_window.cpp | 66 ---- .../example/windows/runner/flutter_window.h | 33 -- .../example/windows/runner/main.cpp | 43 --- .../example/windows/runner/resource.h | 16 - .../windows/runner/resources/app_icon.ico | Bin 33772 -> 0 bytes .../windows/runner/runner.exe.manifest | 20 -- .../example/windows/runner/utils.cpp | 64 ---- .../example/windows/runner/utils.h | 19 -- .../example/windows/runner/win32_window.cpp | 288 ------------------ .../example/windows/runner/win32_window.h | 102 ------- 18 files changed, 1083 deletions(-) delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/.gitignore delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/CMakeLists.txt delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/flutter/CMakeLists.txt delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.cc delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.h delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugins.cmake delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/CMakeLists.txt delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/Runner.rc delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.cpp delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.h delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/main.cpp delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/resource.h delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/resources/app_icon.ico delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/runner.exe.manifest delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.cpp delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.h delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.cpp delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.h diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/.gitignore b/cim-client-sdk/cim-flutter-sdk/example/windows/.gitignore deleted file mode 100644 index d492d0d..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -flutter/ephemeral/ - -# Visual Studio user-specific files. -*.suo -*.user -*.userosscache -*.sln.docstates - -# Visual Studio build-related files. -x64/ -x86/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/CMakeLists.txt b/cim-client-sdk/cim-flutter-sdk/example/windows/CMakeLists.txt deleted file mode 100644 index c027074..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/CMakeLists.txt +++ /dev/null @@ -1,101 +0,0 @@ -# Project-level configuration. -cmake_minimum_required(VERSION 3.14) -project(example LANGUAGES CXX) - -# The name of the executable created for the application. Change this to change -# the on-disk name of your application. -set(BINARY_NAME "example") - -# Explicitly opt in to modern CMake behaviors to avoid warnings with recent -# versions of CMake. -cmake_policy(SET CMP0063 NEW) - -# Define build configuration option. -get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) -if(IS_MULTICONFIG) - set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" - CACHE STRING "" FORCE) -else() - if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - set(CMAKE_BUILD_TYPE "Debug" CACHE - STRING "Flutter build mode" FORCE) - set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS - "Debug" "Profile" "Release") - endif() -endif() -# Define settings for the Profile build mode. -set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") -set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") -set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") -set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") - -# Use Unicode for all projects. -add_definitions(-DUNICODE -D_UNICODE) - -# Compilation settings that should be applied to most targets. -# -# Be cautious about adding new options here, as plugins use this function by -# default. In most cases, you should add new options to specific targets instead -# of modifying this function. -function(APPLY_STANDARD_SETTINGS TARGET) - target_compile_features(${TARGET} PUBLIC cxx_std_17) - target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") - target_compile_options(${TARGET} PRIVATE /EHsc) - target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") - target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") -endfunction() - -# Flutter library and tool build rules. -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") -add_subdirectory(${FLUTTER_MANAGED_DIR}) - -# Application build; see runner/CMakeLists.txt. -add_subdirectory("runner") - -# Generated plugin build rules, which manage building the plugins and adding -# them to the application. -include(flutter/generated_plugins.cmake) - - -# === Installation === -# Support files are copied into place next to the executable, so that it can -# run in place. This is done instead of making a separate bundle (as on Linux) -# so that building and running from within Visual Studio will work. -set(BUILD_BUNDLE_DIR "$") -# Make the "install" step default, as it's required to run. -set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) -endif() - -set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") -set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") - -install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - COMPONENT Runtime) - -install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - -if(PLUGIN_BUNDLED_LIBRARIES) - install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" - DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) -endif() - -# Fully re-copy the assets directory on each build to avoid having stale files -# from a previous install. -set(FLUTTER_ASSET_DIR_NAME "flutter_assets") -install(CODE " - file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") - " COMPONENT Runtime) -install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" - DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) - -# Install the AOT library on non-Debug builds only. -install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" - CONFIGURATIONS Profile;Release - COMPONENT Runtime) diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/CMakeLists.txt b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/CMakeLists.txt deleted file mode 100644 index 930d207..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/CMakeLists.txt +++ /dev/null @@ -1,104 +0,0 @@ -# This file controls Flutter-level build steps. It should not be edited. -cmake_minimum_required(VERSION 3.14) - -set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") - -# Configuration provided via flutter tool. -include(${EPHEMERAL_DIR}/generated_config.cmake) - -# TODO: Move the rest of this into files in ephemeral. See -# https://github.com/flutter/flutter/issues/57146. -set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") - -# === Flutter Library === -set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") - -# Published to parent scope for install step. -set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) -set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) -set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) -set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) - -list(APPEND FLUTTER_LIBRARY_HEADERS - "flutter_export.h" - "flutter_windows.h" - "flutter_messenger.h" - "flutter_plugin_registrar.h" - "flutter_texture_registrar.h" -) -list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") -add_library(flutter INTERFACE) -target_include_directories(flutter INTERFACE - "${EPHEMERAL_DIR}" -) -target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") -add_dependencies(flutter flutter_assemble) - -# === Wrapper === -list(APPEND CPP_WRAPPER_SOURCES_CORE - "core_implementations.cc" - "standard_codec.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") -list(APPEND CPP_WRAPPER_SOURCES_PLUGIN - "plugin_registrar.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") -list(APPEND CPP_WRAPPER_SOURCES_APP - "flutter_engine.cc" - "flutter_view_controller.cc" -) -list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") - -# Wrapper sources needed for a plugin. -add_library(flutter_wrapper_plugin STATIC - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_PLUGIN} -) -apply_standard_settings(flutter_wrapper_plugin) -set_target_properties(flutter_wrapper_plugin PROPERTIES - POSITION_INDEPENDENT_CODE ON) -set_target_properties(flutter_wrapper_plugin PROPERTIES - CXX_VISIBILITY_PRESET hidden) -target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) -target_include_directories(flutter_wrapper_plugin PUBLIC - "${WRAPPER_ROOT}/include" -) -add_dependencies(flutter_wrapper_plugin flutter_assemble) - -# Wrapper sources needed for the runner. -add_library(flutter_wrapper_app STATIC - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_APP} -) -apply_standard_settings(flutter_wrapper_app) -target_link_libraries(flutter_wrapper_app PUBLIC flutter) -target_include_directories(flutter_wrapper_app PUBLIC - "${WRAPPER_ROOT}/include" -) -add_dependencies(flutter_wrapper_app flutter_assemble) - -# === Flutter tool backend === -# _phony_ is a non-existent file to force this command to run every time, -# since currently there's no way to get a full input/output list from the -# flutter tool. -set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") -set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) -add_custom_command( - OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} - ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} - ${CPP_WRAPPER_SOURCES_APP} - ${PHONY_OUTPUT} - COMMAND ${CMAKE_COMMAND} -E env - ${FLUTTER_TOOL_ENVIRONMENT} - "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" - windows-x64 $ - VERBATIM -) -add_custom_target(flutter_assemble DEPENDS - "${FLUTTER_LIBRARY}" - ${FLUTTER_LIBRARY_HEADERS} - ${CPP_WRAPPER_SOURCES_CORE} - ${CPP_WRAPPER_SOURCES_PLUGIN} - ${CPP_WRAPPER_SOURCES_APP} -) diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.cc b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.cc deleted file mode 100644 index 8b6d468..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.cc +++ /dev/null @@ -1,11 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#include "generated_plugin_registrant.h" - - -void RegisterPlugins(flutter::PluginRegistry* registry) { -} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.h b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.h deleted file mode 100644 index dc139d8..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugin_registrant.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// Generated file. Do not edit. -// - -// clang-format off - -#ifndef GENERATED_PLUGIN_REGISTRANT_ -#define GENERATED_PLUGIN_REGISTRANT_ - -#include - -// Registers Flutter plugins. -void RegisterPlugins(flutter::PluginRegistry* registry); - -#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugins.cmake b/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugins.cmake deleted file mode 100644 index b93c4c3..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/flutter/generated_plugins.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# -# Generated file, do not edit. -# - -list(APPEND FLUTTER_PLUGIN_LIST -) - -list(APPEND FLUTTER_FFI_PLUGIN_LIST -) - -set(PLUGIN_BUNDLED_LIBRARIES) - -foreach(plugin ${FLUTTER_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) - target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) - list(APPEND PLUGIN_BUNDLED_LIBRARIES $) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) -endforeach(plugin) - -foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) - add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) - list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) -endforeach(ffi_plugin) diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/CMakeLists.txt b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/CMakeLists.txt deleted file mode 100644 index 394917c..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(runner LANGUAGES CXX) - -# Define the application target. To change its name, change BINARY_NAME in the -# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer -# work. -# -# Any new source files that you add to the application should be added here. -add_executable(${BINARY_NAME} WIN32 - "flutter_window.cpp" - "main.cpp" - "utils.cpp" - "win32_window.cpp" - "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" - "Runner.rc" - "runner.exe.manifest" -) - -# Apply the standard set of build settings. This can be removed for applications -# that need different build settings. -apply_standard_settings(${BINARY_NAME}) - -# Add preprocessor definitions for the build version. -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") -target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") - -# Disable Windows macros that collide with C++ standard library functions. -target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") - -# Add dependency libraries and include directories. Add any application-specific -# dependencies here. -target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) -target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") -target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") - -# Run the Flutter tool portions of the build. This must not be removed. -add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/Runner.rc b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/Runner.rc deleted file mode 100644 index aecaa2b..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/Runner.rc +++ /dev/null @@ -1,121 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#pragma code_page(65001) -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "winres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""winres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_APP_ICON ICON "resources\\app_icon.ico" - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) -#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD -#else -#define VERSION_AS_NUMBER 1,0,0,0 -#endif - -#if defined(FLUTTER_VERSION) -#define VERSION_AS_STRING FLUTTER_VERSION -#else -#define VERSION_AS_STRING "1.0.0" -#endif - -VS_VERSION_INFO VERSIONINFO - FILEVERSION VERSION_AS_NUMBER - PRODUCTVERSION VERSION_AS_NUMBER - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_APP - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904e4" - BEGIN - VALUE "CompanyName", "com.example" "\0" - VALUE "FileDescription", "example" "\0" - VALUE "FileVersion", VERSION_AS_STRING "\0" - VALUE "InternalName", "example" "\0" - VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0" - VALUE "OriginalFilename", "example.exe" "\0" - VALUE "ProductName", "example" "\0" - VALUE "ProductVersion", VERSION_AS_STRING "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1252 - END -END - -#endif // English (United States) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.cpp b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.cpp deleted file mode 100644 index b25e363..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "flutter_window.h" - -#include - -#include "flutter/generated_plugin_registrant.h" - -FlutterWindow::FlutterWindow(const flutter::DartProject& project) - : project_(project) {} - -FlutterWindow::~FlutterWindow() {} - -bool FlutterWindow::OnCreate() { - if (!Win32Window::OnCreate()) { - return false; - } - - RECT frame = GetClientArea(); - - // The size here must match the window dimensions to avoid unnecessary surface - // creation / destruction in the startup path. - flutter_controller_ = std::make_unique( - frame.right - frame.left, frame.bottom - frame.top, project_); - // Ensure that basic setup of the controller was successful. - if (!flutter_controller_->engine() || !flutter_controller_->view()) { - return false; - } - RegisterPlugins(flutter_controller_->engine()); - SetChildContent(flutter_controller_->view()->GetNativeWindow()); - - flutter_controller_->engine()->SetNextFrameCallback([&]() { - this->Show(); - }); - - return true; -} - -void FlutterWindow::OnDestroy() { - if (flutter_controller_) { - flutter_controller_ = nullptr; - } - - Win32Window::OnDestroy(); -} - -LRESULT -FlutterWindow::MessageHandler(HWND hwnd, UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - // Give Flutter, including plugins, an opportunity to handle window messages. - if (flutter_controller_) { - std::optional result = - flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, - lparam); - if (result) { - return *result; - } - } - - switch (message) { - case WM_FONTCHANGE: - flutter_controller_->engine()->ReloadSystemFonts(); - break; - } - - return Win32Window::MessageHandler(hwnd, message, wparam, lparam); -} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.h b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.h deleted file mode 100644 index 6da0652..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/flutter_window.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef RUNNER_FLUTTER_WINDOW_H_ -#define RUNNER_FLUTTER_WINDOW_H_ - -#include -#include - -#include - -#include "win32_window.h" - -// A window that does nothing but host a Flutter view. -class FlutterWindow : public Win32Window { - public: - // Creates a new FlutterWindow hosting a Flutter view running |project|. - explicit FlutterWindow(const flutter::DartProject& project); - virtual ~FlutterWindow(); - - protected: - // Win32Window: - bool OnCreate() override; - void OnDestroy() override; - LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, - LPARAM const lparam) noexcept override; - - private: - // The project to run. - flutter::DartProject project_; - - // The Flutter instance hosted by this window. - std::unique_ptr flutter_controller_; -}; - -#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/main.cpp b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/main.cpp deleted file mode 100644 index a61bf80..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/main.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include -#include -#include - -#include "flutter_window.h" -#include "utils.h" - -int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, - _In_ wchar_t *command_line, _In_ int show_command) { - // Attach to console when present (e.g., 'flutter run') or create a - // new console when running with a debugger. - if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { - CreateAndAttachConsole(); - } - - // Initialize COM, so that it is available for use in the library and/or - // plugins. - ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); - - flutter::DartProject project(L"data"); - - std::vector command_line_arguments = - GetCommandLineArguments(); - - project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); - - FlutterWindow window(project); - Win32Window::Point origin(10, 10); - Win32Window::Size size(1280, 720); - if (!window.Create(L"example", origin, size)) { - return EXIT_FAILURE; - } - window.SetQuitOnClose(true); - - ::MSG msg; - while (::GetMessage(&msg, nullptr, 0, 0)) { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - - ::CoUninitialize(); - return EXIT_SUCCESS; -} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resource.h b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resource.h deleted file mode 100644 index 66a65d1..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Runner.rc -// -#define IDI_APP_ICON 101 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resources/app_icon.ico b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/resources/app_icon.ico deleted file mode 100644 index c04e20caf6370ebb9253ad831cc31de4a9c965f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 33772 zcmeHQc|26z|35SKE&G-*mXah&B~fFkXr)DEO&hIfqby^T&>|8^_Ub8Vp#`BLl3lbZ zvPO!8k!2X>cg~Elr=IVxo~J*a`+9wR=A83c-k-DFd(XM&UI1VKCqM@V;DDtJ09WB} zRaHKiW(GT00brH|0EeTeKVbpbGZg?nK6-j827q-+NFM34gXjqWxJ*a#{b_apGN<-L_m3#8Z26atkEn& ze87Bvv^6vVmM+p+cQ~{u%=NJF>#(d;8{7Q{^rWKWNtf14H}>#&y7$lqmY6xmZryI& z($uy?c5-+cPnt2%)R&(KIWEXww>Cnz{OUpT>W$CbO$h1= z#4BPMkFG1Y)x}Ui+WXr?Z!w!t_hjRq8qTaWpu}FH{MsHlU{>;08goVLm{V<&`itk~ zE_Ys=D(hjiy+5=?=$HGii=Y5)jMe9|wWoD_K07(}edAxh`~LBorOJ!Cf@f{_gNCC| z%{*04ViE!#>@hc1t5bb+NO>ncf@@Dv01K!NxH$3Eg1%)|wLyMDF8^d44lV!_Sr}iEWefOaL z8f?ud3Q%S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QK%<{X22M~2tMulJoa)0*+z9=-YO+;DFEm5eE1U9b^B(Z}2^9!Qk`!A$wUE z7$Ar5?NRg2&G!AZqnmE64eh^Anss3i!{}%6@Et+4rr!=}!SBF8eZ2*J3ujCWbl;3; z48H~goPSv(8X61fKKdpP!Z7$88NL^Z?j`!^*I?-P4X^pMxyWz~@$(UeAcTSDd(`vO z{~rc;9|GfMJcApU3k}22a!&)k4{CU!e_ny^Y3cO;tOvOMKEyWz!vG(Kp*;hB?d|R3`2X~=5a6#^o5@qn?J-bI8Ppip{-yG z!k|VcGsq!jF~}7DMr49Wap-s&>o=U^T0!Lcy}!(bhtYsPQy z4|EJe{12QL#=c(suQ89Mhw9<`bui%nx7Nep`C&*M3~vMEACmcRYYRGtANq$F%zh&V zc)cEVeHz*Z1N)L7k-(k3np#{GcDh2Q@ya0YHl*n7fl*ZPAsbU-a94MYYtA#&!c`xGIaV;yzsmrjfieTEtqB_WgZp2*NplHx=$O{M~2#i_vJ{ps-NgK zQsxKK_CBM2PP_je+Xft`(vYfXXgIUr{=PA=7a8`2EHk)Ym2QKIforz# tySWtj{oF3N9@_;i*Fv5S)9x^z=nlWP>jpp-9)52ZmLVA=i*%6g{{fxOO~wEK diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/runner.exe.manifest b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/runner.exe.manifest deleted file mode 100644 index a42ea76..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/runner.exe.manifest +++ /dev/null @@ -1,20 +0,0 @@ - - - - - PerMonitorV2 - - - - - - - - - - - - - - - diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.cpp b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.cpp deleted file mode 100644 index f5bf9fa..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include "utils.h" - -#include -#include -#include -#include - -#include - -void CreateAndAttachConsole() { - if (::AllocConsole()) { - FILE *unused; - if (freopen_s(&unused, "CONOUT$", "w", stdout)) { - _dup2(_fileno(stdout), 1); - } - if (freopen_s(&unused, "CONOUT$", "w", stderr)) { - _dup2(_fileno(stdout), 2); - } - std::ios::sync_with_stdio(); - FlutterDesktopResyncOutputStreams(); - } -} - -std::vector GetCommandLineArguments() { - // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. - int argc; - wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); - if (argv == nullptr) { - return std::vector(); - } - - std::vector command_line_arguments; - - // Skip the first argument as it's the binary name. - for (int i = 1; i < argc; i++) { - command_line_arguments.push_back(Utf8FromUtf16(argv[i])); - } - - ::LocalFree(argv); - - return command_line_arguments; -} - -std::string Utf8FromUtf16(const wchar_t* utf16_string) { - if (utf16_string == nullptr) { - return std::string(); - } - int target_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, nullptr, 0, nullptr, nullptr); - std::string utf8_string; - if (target_length == 0 || target_length > utf8_string.max_size()) { - return utf8_string; - } - utf8_string.resize(target_length); - int converted_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, utf8_string.data(), - target_length, nullptr, nullptr); - if (converted_length == 0) { - return std::string(); - } - return utf8_string; -} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.h b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.h deleted file mode 100644 index 3879d54..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/utils.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef RUNNER_UTILS_H_ -#define RUNNER_UTILS_H_ - -#include -#include - -// Creates a console for the process, and redirects stdout and stderr to -// it for both the runner and the Flutter library. -void CreateAndAttachConsole(); - -// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string -// encoded in UTF-8. Returns an empty std::string on failure. -std::string Utf8FromUtf16(const wchar_t* utf16_string); - -// Gets the command line arguments passed in as a std::vector, -// encoded in UTF-8. Returns an empty std::vector on failure. -std::vector GetCommandLineArguments(); - -#endif // RUNNER_UTILS_H_ diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.cpp b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.cpp deleted file mode 100644 index 041a385..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.cpp +++ /dev/null @@ -1,288 +0,0 @@ -#include "win32_window.h" - -#include -#include - -#include "resource.h" - -namespace { - -/// Window attribute that enables dark mode window decorations. -/// -/// Redefined in case the developer's machine has a Windows SDK older than -/// version 10.0.22000.0. -/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute -#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE -#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 -#endif - -constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; - -/// Registry key for app theme preference. -/// -/// A value of 0 indicates apps should use dark mode. A non-zero or missing -/// value indicates apps should use light mode. -constexpr const wchar_t kGetPreferredBrightnessRegKey[] = - L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; -constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; - -// The number of Win32Window objects that currently exist. -static int g_active_window_count = 0; - -using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); - -// Scale helper to convert logical scaler values to physical using passed in -// scale factor -int Scale(int source, double scale_factor) { - return static_cast(source * scale_factor); -} - -// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. -// This API is only needed for PerMonitor V1 awareness mode. -void EnableFullDpiSupportIfAvailable(HWND hwnd) { - HMODULE user32_module = LoadLibraryA("User32.dll"); - if (!user32_module) { - return; - } - auto enable_non_client_dpi_scaling = - reinterpret_cast( - GetProcAddress(user32_module, "EnableNonClientDpiScaling")); - if (enable_non_client_dpi_scaling != nullptr) { - enable_non_client_dpi_scaling(hwnd); - } - FreeLibrary(user32_module); -} - -} // namespace - -// Manages the Win32Window's window class registration. -class WindowClassRegistrar { - public: - ~WindowClassRegistrar() = default; - - // Returns the singleton registar instance. - static WindowClassRegistrar* GetInstance() { - if (!instance_) { - instance_ = new WindowClassRegistrar(); - } - return instance_; - } - - // Returns the name of the window class, registering the class if it hasn't - // previously been registered. - const wchar_t* GetWindowClass(); - - // Unregisters the window class. Should only be called if there are no - // instances of the window. - void UnregisterWindowClass(); - - private: - WindowClassRegistrar() = default; - - static WindowClassRegistrar* instance_; - - bool class_registered_ = false; -}; - -WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; - -const wchar_t* WindowClassRegistrar::GetWindowClass() { - if (!class_registered_) { - WNDCLASS window_class{}; - window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); - window_class.lpszClassName = kWindowClassName; - window_class.style = CS_HREDRAW | CS_VREDRAW; - window_class.cbClsExtra = 0; - window_class.cbWndExtra = 0; - window_class.hInstance = GetModuleHandle(nullptr); - window_class.hIcon = - LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); - window_class.hbrBackground = 0; - window_class.lpszMenuName = nullptr; - window_class.lpfnWndProc = Win32Window::WndProc; - RegisterClass(&window_class); - class_registered_ = true; - } - return kWindowClassName; -} - -void WindowClassRegistrar::UnregisterWindowClass() { - UnregisterClass(kWindowClassName, nullptr); - class_registered_ = false; -} - -Win32Window::Win32Window() { - ++g_active_window_count; -} - -Win32Window::~Win32Window() { - --g_active_window_count; - Destroy(); -} - -bool Win32Window::Create(const std::wstring& title, - const Point& origin, - const Size& size) { - Destroy(); - - const wchar_t* window_class = - WindowClassRegistrar::GetInstance()->GetWindowClass(); - - const POINT target_point = {static_cast(origin.x), - static_cast(origin.y)}; - HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); - UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); - double scale_factor = dpi / 96.0; - - HWND window = CreateWindow( - window_class, title.c_str(), WS_OVERLAPPEDWINDOW, - Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), - Scale(size.width, scale_factor), Scale(size.height, scale_factor), - nullptr, nullptr, GetModuleHandle(nullptr), this); - - if (!window) { - return false; - } - - UpdateTheme(window); - - return OnCreate(); -} - -bool Win32Window::Show() { - return ShowWindow(window_handle_, SW_SHOWNORMAL); -} - -// static -LRESULT CALLBACK Win32Window::WndProc(HWND const window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - if (message == WM_NCCREATE) { - auto window_struct = reinterpret_cast(lparam); - SetWindowLongPtr(window, GWLP_USERDATA, - reinterpret_cast(window_struct->lpCreateParams)); - - auto that = static_cast(window_struct->lpCreateParams); - EnableFullDpiSupportIfAvailable(window); - that->window_handle_ = window; - } else if (Win32Window* that = GetThisFromHandle(window)) { - return that->MessageHandler(window, message, wparam, lparam); - } - - return DefWindowProc(window, message, wparam, lparam); -} - -LRESULT -Win32Window::MessageHandler(HWND hwnd, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept { - switch (message) { - case WM_DESTROY: - window_handle_ = nullptr; - Destroy(); - if (quit_on_close_) { - PostQuitMessage(0); - } - return 0; - - case WM_DPICHANGED: { - auto newRectSize = reinterpret_cast(lparam); - LONG newWidth = newRectSize->right - newRectSize->left; - LONG newHeight = newRectSize->bottom - newRectSize->top; - - SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, - newHeight, SWP_NOZORDER | SWP_NOACTIVATE); - - return 0; - } - case WM_SIZE: { - RECT rect = GetClientArea(); - if (child_content_ != nullptr) { - // Size and position the child window. - MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, - rect.bottom - rect.top, TRUE); - } - return 0; - } - - case WM_ACTIVATE: - if (child_content_ != nullptr) { - SetFocus(child_content_); - } - return 0; - - case WM_DWMCOLORIZATIONCOLORCHANGED: - UpdateTheme(hwnd); - return 0; - } - - return DefWindowProc(window_handle_, message, wparam, lparam); -} - -void Win32Window::Destroy() { - OnDestroy(); - - if (window_handle_) { - DestroyWindow(window_handle_); - window_handle_ = nullptr; - } - if (g_active_window_count == 0) { - WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); - } -} - -Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { - return reinterpret_cast( - GetWindowLongPtr(window, GWLP_USERDATA)); -} - -void Win32Window::SetChildContent(HWND content) { - child_content_ = content; - SetParent(content, window_handle_); - RECT frame = GetClientArea(); - - MoveWindow(content, frame.left, frame.top, frame.right - frame.left, - frame.bottom - frame.top, true); - - SetFocus(child_content_); -} - -RECT Win32Window::GetClientArea() { - RECT frame; - GetClientRect(window_handle_, &frame); - return frame; -} - -HWND Win32Window::GetHandle() { - return window_handle_; -} - -void Win32Window::SetQuitOnClose(bool quit_on_close) { - quit_on_close_ = quit_on_close; -} - -bool Win32Window::OnCreate() { - // No-op; provided for subclasses. - return true; -} - -void Win32Window::OnDestroy() { - // No-op; provided for subclasses. -} - -void Win32Window::UpdateTheme(HWND const window) { - DWORD light_mode; - DWORD light_mode_size = sizeof(light_mode); - LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, - kGetPreferredBrightnessRegValue, - RRF_RT_REG_DWORD, nullptr, &light_mode, - &light_mode_size); - - if (result == ERROR_SUCCESS) { - BOOL enable_dark_mode = light_mode == 0; - DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, - &enable_dark_mode, sizeof(enable_dark_mode)); - } -} diff --git a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.h b/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.h deleted file mode 100644 index c86632d..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/windows/runner/win32_window.h +++ /dev/null @@ -1,102 +0,0 @@ -#ifndef RUNNER_WIN32_WINDOW_H_ -#define RUNNER_WIN32_WINDOW_H_ - -#include - -#include -#include -#include - -// A class abstraction for a high DPI-aware Win32 Window. Intended to be -// inherited from by classes that wish to specialize with custom -// rendering and input handling -class Win32Window { - public: - struct Point { - unsigned int x; - unsigned int y; - Point(unsigned int x, unsigned int y) : x(x), y(y) {} - }; - - struct Size { - unsigned int width; - unsigned int height; - Size(unsigned int width, unsigned int height) - : width(width), height(height) {} - }; - - Win32Window(); - virtual ~Win32Window(); - - // Creates a win32 window with |title| that is positioned and sized using - // |origin| and |size|. New windows are created on the default monitor. Window - // sizes are specified to the OS in physical pixels, hence to ensure a - // consistent size this function will scale the inputted width and height as - // as appropriate for the default monitor. The window is invisible until - // |Show| is called. Returns true if the window was created successfully. - bool Create(const std::wstring& title, const Point& origin, const Size& size); - - // Show the current window. Returns true if the window was successfully shown. - bool Show(); - - // Release OS resources associated with window. - void Destroy(); - - // Inserts |content| into the window tree. - void SetChildContent(HWND content); - - // Returns the backing Window handle to enable clients to set icon and other - // window properties. Returns nullptr if the window has been destroyed. - HWND GetHandle(); - - // If true, closing this window will quit the application. - void SetQuitOnClose(bool quit_on_close); - - // Return a RECT representing the bounds of the current client area. - RECT GetClientArea(); - - protected: - // Processes and route salient window messages for mouse handling, - // size change and DPI. Delegates handling of these to member overloads that - // inheriting classes can handle. - virtual LRESULT MessageHandler(HWND window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept; - - // Called when CreateAndShow is called, allowing subclass window-related - // setup. Subclasses should return false if setup fails. - virtual bool OnCreate(); - - // Called when Destroy is called. - virtual void OnDestroy(); - - private: - friend class WindowClassRegistrar; - - // OS callback called by message pump. Handles the WM_NCCREATE message which - // is passed when the non-client area is being created and enables automatic - // non-client DPI scaling so that the non-client area automatically - // responsponds to changes in DPI. All other messages are handled by - // MessageHandler. - static LRESULT CALLBACK WndProc(HWND const window, - UINT const message, - WPARAM const wparam, - LPARAM const lparam) noexcept; - - // Retrieves a class instance pointer for |window| - static Win32Window* GetThisFromHandle(HWND const window) noexcept; - - // Update the window frame's theme to match the system theme. - static void UpdateTheme(HWND const window); - - bool quit_on_close_ = false; - - // window handle for top level window. - HWND window_handle_ = nullptr; - - // window handle for hosted content. - HWND child_content_ = nullptr; -}; - -#endif // RUNNER_WIN32_WINDOW_H_ From 2a8ec5865e8c5ddaf8debaab0ae7e54319536eab Mon Sep 17 00:00:00 2001 From: yangjiejie12308 <38904385+yangjiejie12308@users.noreply.github.com> Date: Thu, 6 Jul 2023 11:43:52 +0800 Subject: [PATCH 07/12] fix osversion is too long --- .../cim-flutter-sdk/.flutter-plugins | 2 +- .../.flutter-plugins-dependencies | 2 +- cim-client-sdk/cim-flutter-sdk/CHANGELOG.md | 4 +- cim-client-sdk/cim-flutter-sdk/README.md | 2 +- .../cim-flutter-sdk/example/pubspec.lock | 76 +++++++++---------- .../cim-flutter-sdk/lib/cim_socket.dart | 12 +-- cim-client-sdk/cim-flutter-sdk/pubspec.yaml | 2 +- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins index 622aef1..cc0805d 100644 --- a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins +++ b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins @@ -1,2 +1,2 @@ # This is a generated file; do not edit or check into version control. -device_info_plus=C:\\Users\\smeb\\AppData\\Local\\Pub\\Cache\\hosted\\pub.flutter-io.cn\\device_info_plus-8.2.2\\ +device_info_plus=C:\\Users\\smeb\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\device_info_plus-8.2.2\\ diff --git a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies index c214ef8..362bbf9 100644 --- a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies +++ b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies @@ -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.flutter-io.cn\\\\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.flutter-io.cn\\\\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.flutter-io.cn\\\\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.flutter-io.cn\\\\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.flutter-io.cn\\\\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.flutter-io.cn\\\\device_info_plus-8.2.2\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]}],"date_created":"2023-07-04 15:53:37.990976","version":"3.7.7"} \ No newline at end of file +{"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-06 11:06:37.470895","version":"3.7.7"} \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md index 6ce5242..0aae02e 100644 --- a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md +++ b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md @@ -1,3 +1,3 @@ -## 1.0.1 +## 1.0.2 -* 支持所有平台 +* 修复version字段过长的错误 diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/README.md index 6aa9853..76e9e86 100644 --- a/cim-client-sdk/cim-flutter-sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/README.md @@ -9,7 +9,7 @@ ``` dependencies: - cim_flutter_sdk:^1.0.1 + cim_flutter_sdk: ^1.0.2 ``` diff --git a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock index 13b05ea..8e8f4d0 100644 --- a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock +++ b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock @@ -6,7 +6,7 @@ packages: description: name: async sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.10.0" boolean_selector: @@ -14,7 +14,7 @@ packages: description: name: boolean_selector sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.1" characters: @@ -22,7 +22,7 @@ packages: description: name: characters sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.1" cim_flutter_sdk: @@ -31,13 +31,13 @@ packages: path: ".." relative: true source: path - version: "1.0.1" + version: "1.0.2" clock: dependency: transitive description: name: clock sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.1" collection: @@ -45,7 +45,7 @@ packages: description: name: collection sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.17.0" common_utils: @@ -53,7 +53,7 @@ packages: description: name: common_utils sha256: c26884339b13ff99b0739e56f4b02090c84054ed9dd3a045435cd24e7b99c2c1 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.0" convert: @@ -61,7 +61,7 @@ packages: description: name: convert sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.1.1" crypto: @@ -69,7 +69,7 @@ packages: description: name: crypto sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "3.0.3" cupertino_icons: @@ -77,7 +77,7 @@ packages: description: name: cupertino_icons sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.0.5" decimal: @@ -85,7 +85,7 @@ packages: description: name: decimal sha256: eece91944f523657c75a3a008a90ec7f7eb3986191153a78570c7d0ac8ef3d01 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.3.2" device_info_plus: @@ -93,7 +93,7 @@ packages: description: name: device_info_plus sha256: f52ab3b76b36ede4d135aab80194df8925b553686f0fa12226b4e2d658e45903 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "8.2.2" device_info_plus_platform_interface: @@ -101,7 +101,7 @@ packages: description: name: device_info_plus_platform_interface sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "7.0.0" fake_async: @@ -109,7 +109,7 @@ packages: description: name: fake_async sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.3.1" ffi: @@ -117,7 +117,7 @@ packages: description: name: ffi sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.2" file: @@ -125,7 +125,7 @@ packages: description: name: file sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "6.1.4" fixnum: @@ -133,7 +133,7 @@ packages: description: name: fixnum sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.1.0" flutter: @@ -145,10 +145,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c - url: "https://pub.flutter-io.cn" + sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" + url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter @@ -164,7 +164,7 @@ packages: description: name: js sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.6.5" lints: @@ -172,7 +172,7 @@ packages: description: name: lints sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.0.1" matcher: @@ -180,7 +180,7 @@ packages: description: name: matcher sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.12.13" material_color_utilities: @@ -188,7 +188,7 @@ packages: description: name: material_color_utilities sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.2.0" meta: @@ -196,7 +196,7 @@ packages: description: name: meta sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.8.0" path: @@ -204,7 +204,7 @@ packages: description: name: path sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.8.2" plugin_platform_interface: @@ -212,7 +212,7 @@ packages: description: name: plugin_platform_interface sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.4" protobuf: @@ -220,7 +220,7 @@ packages: description: name: protobuf sha256: "01dd9bd0fa02548bf2ceee13545d4a0ec6046459d847b6b061d8a27237108a08" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.0" rational: @@ -228,7 +228,7 @@ packages: description: name: rational sha256: ba58e9e18df9abde280e8b10051e4bce85091e41e8e7e411b6cde2e738d357cf - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.2.2" sky_engine: @@ -241,7 +241,7 @@ packages: description: name: source_span sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.9.1" stack_trace: @@ -249,7 +249,7 @@ packages: description: name: stack_trace sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.11.0" stream_channel: @@ -257,7 +257,7 @@ packages: description: name: stream_channel sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.1" string_scanner: @@ -265,7 +265,7 @@ packages: description: name: string_scanner sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.0" term_glyph: @@ -273,7 +273,7 @@ packages: description: name: term_glyph sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.2.1" test_api: @@ -281,7 +281,7 @@ packages: description: name: test_api sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "0.4.16" typed_data: @@ -289,7 +289,7 @@ packages: description: name: typed_data sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "1.3.2" vector_math: @@ -297,7 +297,7 @@ packages: description: name: vector_math sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "2.1.4" win32: @@ -305,7 +305,7 @@ packages: description: name: win32 sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" - url: "https://pub.flutter-io.cn" + url: "https://pub.dev" source: hosted version: "4.1.4" sdks: diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart index ef418ae..04b00d2 100644 --- a/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart +++ b/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart @@ -223,36 +223,36 @@ class SystemInfo { // Android相关代码 var value = await deviceInfoPlugin.androidInfo; deviceName = 'android'; - version = value.version.release; + version = Platform.version.substring(0, 6); deviceId = value.id; model = value.model; } else if (Platform.isIOS) { // iOS相关代码 var value = await deviceInfoPlugin.iosInfo; deviceName = 'ios'; - version = value.systemVersion!; + version = Platform.version.substring(0, 6); deviceId = value.identifierForVendor!; model = value.model!; } else if (Platform.isMacOS) { // MacOS相关代码 var value = await deviceInfoPlugin.macOsInfo; - deviceName = 'macos'; - version = value.kernelVersion; + deviceName = 'mac'; + version = Platform.version.substring(0, 6); deviceId = value.model; model = value.model; } else if (Platform.isWindows) { // Windows相关代码 var value = await deviceInfoPlugin.windowsInfo; deviceName = 'windows'; - version = value.displayVersion; + version = Platform.version.substring(0, 6); deviceId = value.deviceId; model = value.majorVersion.toString(); } else if (Platform.isLinux) { // Linux相关代码 var value = await deviceInfoPlugin.linuxInfo; deviceName = 'linux'; - version = value.version!; + version = Platform.version.substring(0, 6); deviceId = value.id; model = value.version!; } diff --git a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml index 36bde2f..260105a 100644 --- a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml +++ b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml @@ -1,7 +1,7 @@ name: cim_flutter_sdk description: a flutter sdk for cim. repository: https://gitee.com/farsunset/cim -version: 1.0.1 +version: 1.0.2 homepage: http://farsunset.com/ environment: From d7e8649c1781c7a6bd9d0da58084f1ed410b2e0e Mon Sep 17 00:00:00 2001 From: yangjiejie12308 <38904385+yangjiejie12308@users.noreply.github.com> Date: Mon, 10 Jul 2023 10:46:43 +0800 Subject: [PATCH 08/12] =?UTF-8?q?fix=20=E9=87=8D=E5=A4=8D=E6=94=B6?= =?UTF-8?q?=E5=88=B0=E6=B6=88=E6=81=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.flutter-plugins-dependencies | 2 +- cim-client-sdk/cim-flutter-sdk/CHANGELOG.md | 4 +- cim-client-sdk/cim-flutter-sdk/README.md | 42 ++++++++++----- .../cim-flutter-sdk/example/lib/main.dart | 47 ++++++++-------- .../cim-flutter-sdk/example/pubspec.lock | 2 +- .../cim-flutter-sdk/lib/cim_flutter_sdk.dart | 21 -------- .../lib/cim_flutter_sdk_method_channel.dart | 17 ------ .../cim_flutter_sdk_platform_interface.dart | 29 ---------- .../cim-flutter-sdk/lib/cim_socket.dart | 54 +++++-------------- cim-client-sdk/cim-flutter-sdk/pubspec.yaml | 3 +- 10 files changed, 67 insertions(+), 154 deletions(-) delete mode 100644 cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart delete mode 100644 cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_method_channel.dart delete mode 100644 cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_platform_interface.dart diff --git a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies index 362bbf9..7529ebd 100644 --- a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies +++ b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies @@ -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-06 11:06:37.470895","version":"3.7.7"} \ No newline at end of file +{"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-07 10:37:13.109602","version":"3.7.7"} \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md index 0aae02e..bc44140 100644 --- a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md +++ b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md @@ -1,3 +1,3 @@ -## 1.0.2 +## 1.0.3 -* 修复version字段过长的错误 +* 修复重复收到消息的BUG diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/README.md index 76e9e86..1fe0048 100644 --- a/cim-client-sdk/cim-flutter-sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/README.md @@ -9,7 +9,7 @@ ``` dependencies: - cim_flutter_sdk: ^1.0.2 + cim_flutter_sdk: ^1.0.3 ``` @@ -19,30 +19,44 @@ dependencies: import 'package:cim_flutter_sdk/cim_socket.dart'; ... -final CIMSocket cimSocket = CIMSocket(); + late CIMSocket? cimSocket = null; -String Message = 'Unknown'; + late List list = []; - cimSocket.init('127.0.0.1', 34567, 16501516154949); - cimSocket.connect(); - cimSocket.addListener(() { - if (cimSocket.model == null) return; - setState(() { - Message = cimSocket.model!.toProto3Json().toString(); - }); + late bool connectStatus = false; + + @override + void initState() { + super.initState(); + cimSocket = CIMSocket(onMessageReceived: (value) { + setState(() { + list.add(value.toProto3Json().toString()); }); - + }, onConnectionStatusChanged: (value) { + setState(() { + connectStatus = value; + }); + }); + cimSocket!.init('127.0.0.1', 34567, 16501516154949); + cimSocket!.connect(); + } ... + @override + Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( - title: const Text('Plugin example app'), + title: Text(connectStatus ? '已连接' : '未连接'), ), - body: Center( - child: Text('Message is: $Message\n'), + body: ListView.builder( + itemCount: list.length, + itemBuilder: (context, index) { + return Text(list[index]); + }, ), ), ); + } ``` diff --git a/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart b/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart index cd8bb01..6562fee 100644 --- a/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart +++ b/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart @@ -16,32 +16,26 @@ class MyApp extends StatefulWidget { } class _MyAppState extends State { - String Message = 'Unknown'; + late CIMSocket? cimSocket = null; + + late List list = []; + + late bool connectStatus = false; + @override void initState() { super.initState(); - initCimState(); - } - - final CIMSocket cimSocket = CIMSocket(); - // Platform messages are asynchronous, so we initialize in an async method. - Future initCimState() async { - // Platform messages may fail, so we use a try/catch PlatformException. - // We also handle the message potentially returning null. - try { - cimSocket.init('api.hoxin.farsunset.com', 34567, 16501516154949); - cimSocket.connect(); - cimSocket.addListener(() { - if (cimSocket.model == null) return; - setState(() { - Message = cimSocket.model!.toProto3Json().toString(); - }); + cimSocket = CIMSocket(onMessageReceived: (value) { + setState(() { + list.add(value.toProto3Json().toString()); }); - } on PlatformException {} - - // If the widget was removed from the tree while the asynchronous platform - // message was in flight, we want to discard the reply rather than calling - // setState to update our non-existent appearance. + }, onConnectionStatusChanged: (value) { + setState(() { + connectStatus = value; + }); + }); + cimSocket!.init('api.hoxin.farsunset.com', 34567, 16501516154949); + cimSocket!.connect(); } @override @@ -49,10 +43,13 @@ class _MyAppState extends State { return MaterialApp( home: Scaffold( appBar: AppBar( - title: const Text('Plugin example app'), + title: Text(connectStatus ? '已连接' : '未连接'), ), - body: Center( - child: Text('Message is: $Message\n'), + body: ListView.builder( + itemCount: list.length, + itemBuilder: (context, index) { + return Text(list[index]); + }, ), ), ); diff --git a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock index 8e8f4d0..849852f 100644 --- a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock +++ b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock @@ -31,7 +31,7 @@ packages: path: ".." relative: true source: path - version: "1.0.2" + version: "1.0.3" clock: dependency: transitive description: diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart deleted file mode 100644 index 9c9ccfd..0000000 --- a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk.dart +++ /dev/null @@ -1,21 +0,0 @@ -// You have generated a new plugin project without specifying the `--platforms` -// flag. A plugin project with no platform support was generated. To add a -// platform, run `flutter create -t plugin --platforms .` under the -// same directory. You can also find a detailed instruction on how to add -// platforms in the `pubspec.yaml` at -// https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms. - -import 'cim_socket.dart'; - -class CimFlutterSdk { - final CIMSocket cimSocket = CIMSocket(); - Future connect(String uri, int port, int uid) async { - cimSocket.init(uri, port, uid); - cimSocket.connect(); - return cimSocket; - } - - Future disconnect() async { - cimSocket.disConnect(); - } -} diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_method_channel.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_method_channel.dart deleted file mode 100644 index f2be325..0000000 --- a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_method_channel.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; - -import 'cim_flutter_sdk_platform_interface.dart'; - -/// An implementation of [CimFlutterSdkPlatform] that uses method channels. -class MethodChannelCimFlutterSdk extends CimFlutterSdkPlatform { - /// The method channel used to interact with the native platform. - @visibleForTesting - final methodChannel = const MethodChannel('cim_flutter_sdk'); - - @override - Future getPlatformVersion() async { - final version = await methodChannel.invokeMethod('getPlatformVersion'); - return version; - } -} diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_platform_interface.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_platform_interface.dart deleted file mode 100644 index 46d6d9c..0000000 --- a/cim-client-sdk/cim-flutter-sdk/lib/cim_flutter_sdk_platform_interface.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'package:plugin_platform_interface/plugin_platform_interface.dart'; - -import 'cim_flutter_sdk_method_channel.dart'; - -abstract class CimFlutterSdkPlatform extends PlatformInterface { - /// Constructs a CimFlutterSdkPlatform. - CimFlutterSdkPlatform() : super(token: _token); - - static final Object _token = Object(); - - static CimFlutterSdkPlatform _instance = MethodChannelCimFlutterSdk(); - - /// The default instance of [CimFlutterSdkPlatform] to use. - /// - /// Defaults to [MethodChannelCimFlutterSdk]. - static CimFlutterSdkPlatform get instance => _instance; - - /// Platform-specific implementations should set this with their own - /// platform-specific class that extends [CimFlutterSdkPlatform] when - /// they register themselves. - static set instance(CimFlutterSdkPlatform instance) { - PlatformInterface.verifyToken(instance, _token); - _instance = instance; - } - - Future getPlatformVersion() { - throw UnimplementedError('platformVersion() has not been implemented.'); - } -} diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart index 04b00d2..48b9eef 100644 --- a/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart +++ b/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart @@ -38,13 +38,19 @@ const DATA_HEADER_LENGTH = 1; const sOCKETAPPVERSION = '100'; -class CIMSocket extends ChangeNotifier { +class CIMSocket { + CIMSocket( + {required this.onMessageReceived, + required this.onConnectionStatusChanged}); + late Socket? socket; late String? uri; late int? port; late int? uid; late String endCode = "0"; final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); + final ValueChanged onMessageReceived; + final ValueChanged onConnectionStatusChanged; late TimerUtil timer = TimerUtil() ..mTotalTime = 10000 ..setOnTimerTickCallback((millisUntilFinished) { @@ -52,11 +58,6 @@ class CIMSocket extends ChangeNotifier { connect(); } }); - late bool isConnected = false; - - late messages.Model? _model = null; - - messages.Model? get model => _model; Future init(String uri, int port, int uid) async { this.uri = uri; @@ -84,33 +85,30 @@ class CIMSocket extends ChangeNotifier { var message = data.sublist(3, length + 3); messages.Model model = messages.Model(); model.mergeFromBuffer(message); - switchMessage(model); + onMessageReceived(model); } }, onError: (error, StackTrace trace) { socket = null; - isConnected = false; if (!timer.isActive()) { timer.setTotalTime(12000); timer.startCountDown(); } - notifyListeners(); + onConnectionStatusChanged(false); }, onDone: () { socket = null; - isConnected = false; - notifyListeners(); if (endCode != "999") { timer.setTotalTime(12000); timer.startCountDown(); } + onConnectionStatusChanged(false); }, cancelOnError: true); socket = sock; sendLoginMsg(); }).catchError((e) { socket = null; - isConnected = false; - notifyListeners(); timer.setTotalTime(12000); timer.startCountDown(); + onConnectionStatusChanged(false); }); } @@ -157,30 +155,10 @@ class CIMSocket extends ChangeNotifier { protobuf.setRange(3, data.length + 3, data); socket!.add(protobuf); await socket!.flush(); - isConnected = true; + onConnectionStatusChanged(true); if (timer.isActive()) { timer.cancel(); } - notifyListeners(); - } - - /// 发送群组聊天 tag - Future sendTag(String tag) async { - Map map1 = {"tag": tag}; - int time = DateTime.now().millisecondsSinceEpoch; - Int64 timeStamp = Int64.parseInt(time.toString()); - var body = sentbody.Model(data: map1); - body.key = "client_set_tag"; - body.timestamp = timeStamp; - var data = body.writeToBuffer(); - var protobuf = Uint8List(data.length + 3); - protobuf[0] = 3; - protobuf[1] = (data.length & 0xff); - protobuf[2] = ((data.length >> 8) & 0xff); - protobuf.setRange(3, data.length + 3, data); - socket!.add(protobuf); - await socket!.flush(); - return 2; } //发送PONG响应 @@ -197,17 +175,9 @@ class CIMSocket extends ChangeNotifier { pONG.setRange(3, 6, pONGBODY); socket!.add(pONG); await socket!.flush(); - isConnected = true; if (timer.isActive()) { timer.cancel(); } - notifyListeners(); - } - - ///消息分发器 - Future switchMessage(messages.Model model) async { - _model = model; - notifyListeners(); } } diff --git a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml index 260105a..0af8d38 100644 --- a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml +++ b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml @@ -1,7 +1,7 @@ name: cim_flutter_sdk description: a flutter sdk for cim. repository: https://gitee.com/farsunset/cim -version: 1.0.2 +version: 1.0.3 homepage: http://farsunset.com/ environment: @@ -11,7 +11,6 @@ environment: dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.0.2 protobuf: ^2.0.1 # Google protobuf 序列化 device_info_plus: ^8.2.2 common_utils: ^2.1.0 From 03a309d8ee707d2565950e261a5dd58c4cecb3ff Mon Sep 17 00:00:00 2001 From: yangjiejie12308 <38904385+yangjiejie12308@users.noreply.github.com> Date: Thu, 13 Jul 2023 17:25:37 +0800 Subject: [PATCH 09/12] =?UTF-8?q?fix=20=E5=85=81=E8=AE=B8UID=20=E4=B8=BA?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cim-flutter-sdk/.flutter-plugins-dependencies | 2 +- cim-client-sdk/cim-flutter-sdk/CHANGELOG.md | 4 ++-- cim-client-sdk/cim-flutter-sdk/README.md | 4 ++-- cim-client-sdk/cim-flutter-sdk/example/lib/main.dart | 2 +- cim-client-sdk/cim-flutter-sdk/example/pubspec.lock | 2 +- cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart | 6 +++--- cim-client-sdk/cim-flutter-sdk/pubspec.yaml | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies index 7529ebd..1975384 100644 --- a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies +++ b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies @@ -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-07 10:37:13.109602","version":"3.7.7"} \ No newline at end of file +{"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-13 17:24:04.445236","version":"3.7.7"} \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md index bc44140..a0b0b55 100644 --- a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md +++ b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md @@ -1,3 +1,3 @@ -## 1.0.3 +## 1.0.4 -* 修复重复收到消息的BUG +* 允许链接到服务器的UID为字符串 diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/README.md index 1fe0048..5adc045 100644 --- a/cim-client-sdk/cim-flutter-sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/README.md @@ -9,7 +9,7 @@ ``` dependencies: - cim_flutter_sdk: ^1.0.3 + cim_flutter_sdk: ^1.0.4 ``` @@ -37,7 +37,7 @@ import 'package:cim_flutter_sdk/cim_socket.dart'; connectStatus = value; }); }); - cimSocket!.init('127.0.0.1', 34567, 16501516154949); + cimSocket!.init('127.0.0.1', 34567, '16501516154949'); cimSocket!.connect(); } ... diff --git a/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart b/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart index 6562fee..a67cbba 100644 --- a/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart +++ b/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart @@ -34,7 +34,7 @@ class _MyAppState extends State { connectStatus = value; }); }); - cimSocket!.init('api.hoxin.farsunset.com', 34567, 16501516154949); + cimSocket!.init('api.hoxin.farsunset.com', 34567, '16501516154949'); cimSocket!.connect(); } diff --git a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock index 849852f..93b0b7e 100644 --- a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock +++ b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock @@ -31,7 +31,7 @@ packages: path: ".." relative: true source: path - version: "1.0.3" + version: "1.0.4" clock: dependency: transitive description: diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart b/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart index 48b9eef..1df90c0 100644 --- a/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart +++ b/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart @@ -46,7 +46,7 @@ class CIMSocket { late Socket? socket; late String? uri; late int? port; - late int? uid; + late String? uid; late String endCode = "0"; final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); final ValueChanged onMessageReceived; @@ -59,7 +59,7 @@ class CIMSocket { } }); - Future init(String uri, int port, int uid) async { + Future init(String uri, int port, String uid) async { this.uri = uri; this.port = port; this.uid = uid; @@ -132,7 +132,7 @@ class CIMSocket { md5.convert(const Utf8Encoder().convert(systemInfo.deviceId)).bytes); Map map = { - "uid": uid.toString(), //主id + "uid": uid!, //主id "channel": channel, "appVersion": sOCKETAPPVERSION, "osVersion": systemVersion, diff --git a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml index 0af8d38..84e37f7 100644 --- a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml +++ b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml @@ -1,7 +1,7 @@ name: cim_flutter_sdk description: a flutter sdk for cim. repository: https://gitee.com/farsunset/cim -version: 1.0.3 +version: 1.0.4 homepage: http://farsunset.com/ environment: From 2a3d315d75b324c7957205ee08774d7e5d9d7c7f Mon Sep 17 00:00:00 2001 From: yangjiejie12308 <38904385+yangjiejie12308@users.noreply.github.com> Date: Fri, 14 Jul 2023 10:33:26 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=E6=9B=B4=E6=96=B0sdk=20websocket=20sdk?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.flutter-plugins-dependencies | 2 +- cim-client-sdk/cim-flutter-sdk/CHANGELOG.md | 4 +-- cim-client-sdk/cim-flutter-sdk/README.md | 7 ++++- .../cim-flutter-sdk/example/.metadata | 2 +- .../cim-flutter-sdk/example/pubspec.lock | 2 +- .../example/test/widget_test.dart | 27 ------------------- cim-client-sdk/cim-flutter-sdk/pubspec.yaml | 4 +-- 7 files changed, 13 insertions(+), 35 deletions(-) delete mode 100644 cim-client-sdk/cim-flutter-sdk/example/test/widget_test.dart diff --git a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies index 1975384..7519b45 100644 --- a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies +++ b/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies @@ -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-13 17:24:04.445236","version":"3.7.7"} \ No newline at end of file +{"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:32:14.638138","version":"3.7.7"} \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md index a0b0b55..34cfda1 100644 --- a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md +++ b/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md @@ -1,3 +1,3 @@ -## 1.0.4 +## 1.0.5 -* 允许链接到服务器的UID为字符串 +* allow connect string uid type are string. update readme.md diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/README.md index 5adc045..ffc5859 100644 --- a/cim-client-sdk/cim-flutter-sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/README.md @@ -2,6 +2,11 @@ 开源通讯库 [CIM](https://gitee.com/farsunset/cim) 的 flutter版本SDK + +## WebSocket版本 + +[在这里](https://pub.dev/packages/cim_flutter_websocket_sdk) + ## 如何在自己的项目中引用SDK 在 pubspec.yaml 引入 @@ -9,7 +14,7 @@ ``` dependencies: - cim_flutter_sdk: ^1.0.4 + cim_flutter_sdk: ^1.0.5 ``` diff --git a/cim-client-sdk/cim-flutter-sdk/example/.metadata b/cim-client-sdk/cim-flutter-sdk/example/.metadata index b1fefbe..8245e38 100644 --- a/cim-client-sdk/cim-flutter-sdk/example/.metadata +++ b/cim-client-sdk/cim-flutter-sdk/example/.metadata @@ -15,7 +15,7 @@ migration: - platform: root create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da - - platform: windows + - platform: web create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da diff --git a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock index 93b0b7e..eede5ce 100644 --- a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock +++ b/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock @@ -31,7 +31,7 @@ packages: path: ".." relative: true source: path - version: "1.0.4" + version: "1.0.5" clock: dependency: transitive description: diff --git a/cim-client-sdk/cim-flutter-sdk/example/test/widget_test.dart b/cim-client-sdk/cim-flutter-sdk/example/test/widget_test.dart deleted file mode 100644 index 6221123..0000000 --- a/cim-client-sdk/cim-flutter-sdk/example/test/widget_test.dart +++ /dev/null @@ -1,27 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:cim_flutter_sdk_example/main.dart'; - -void main() { - testWidgets('Verify Platform version', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that platform version is retrieved. - expect( - find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data!.startsWith('Running on:'), - ), - findsOneWidget, - ); - }); -} diff --git a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml index 84e37f7..227e088 100644 --- a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml +++ b/cim-client-sdk/cim-flutter-sdk/pubspec.yaml @@ -1,7 +1,7 @@ name: cim_flutter_sdk -description: a flutter sdk for cim. +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.4 +version: 1.0.5 homepage: http://farsunset.com/ environment: From df3385151a406e61129ca7ed9b797fec731ec9df Mon Sep 17 00:00:00 2001 From: yangjiejie12308 <38904385+yangjiejie12308@users.noreply.github.com> Date: Fri, 14 Jul 2023 11:22:34 +0800 Subject: [PATCH 11/12] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20flutter=5Fwebsocket?= =?UTF-8?q?=5Fsdk=20=E6=94=AF=E6=8C=81=E6=89=80=E6=9C=89=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => cim_flutter_sdk}/.flutter-plugins | 0 .../.flutter-plugins-dependencies | 2 +- .../{ => cim_flutter_sdk}/.gitignore | 0 .../{ => cim_flutter_sdk}/.metadata | 0 .../{ => cim_flutter_sdk}/CHANGELOG.md | 0 .../{ => cim_flutter_sdk}/LICENSE | 0 .../{ => cim_flutter_sdk}/README.md | 0 .../analysis_options.yaml | 0 .../{ => cim_flutter_sdk}/example/.gitignore | 0 .../{ => cim_flutter_sdk}/example/.metadata | 0 .../{ => cim_flutter_sdk}/example/README.md | 0 .../example/analysis_options.yaml | 0 .../example/lib/main.dart | 0 .../example/pubspec.lock | 0 .../example/pubspec.yaml | 0 .../{ => cim_flutter_sdk}/lib/Message.pb.dart | 0 .../lib/Message.pbenum.dart | 0 .../lib/Message.pbjson.dart | 0 .../lib/Message.pbserver.dart | 0 .../{ => cim_flutter_sdk}/lib/Message.proto | 0 .../lib/ReplyBody.pb.dart | 0 .../lib/ReplyBody.pbenum.dart | 0 .../lib/ReplyBody.pbjson.dart | 0 .../lib/ReplyBody.pbserver.dart | 0 .../{ => cim_flutter_sdk}/lib/ReplyBody.proto | 0 .../lib/SentBody.pb.dart | 0 .../lib/SentBody.pbenum.dart | 0 .../lib/SentBody.pbjson.dart | 0 .../lib/SentBody.pbserver.dart | 0 .../{ => cim_flutter_sdk}/lib/SentBody.proto | 0 .../{ => cim_flutter_sdk}/lib/cim_socket.dart | 0 .../{ => cim_flutter_sdk}/pubspec.yaml | 2 +- .../.flutter-plugins | 2 + .../.flutter-plugins-dependencies | 1 + .../cim_flutter_websocket_sdk/.gitignore | 30 ++ .../cim_flutter_websocket_sdk/.metadata | 27 ++ .../cim_flutter_websocket_sdk/CHANGELOG.md | 3 + .../cim_flutter_websocket_sdk/LICENSE | 25 ++ .../cim_flutter_websocket_sdk/README.md | 67 ++++ .../analysis_options.yaml | 4 + .../example/.gitignore | 44 +++ .../example/.metadata | 30 ++ .../example/README.md | 16 + .../example/analysis_options.yaml | 29 ++ .../example/lib/main.dart | 54 ++++ .../example/pubspec.lock | 289 ++++++++++++++++++ .../example/pubspec.yaml | 82 +++++ .../lib/Message.pb.dart | 171 +++++++++++ .../lib/Message.pbenum.dart | 7 + .../lib/Message.pbjson.dart | 28 ++ .../lib/Message.pbserver.dart | 9 + .../lib/Message.proto | 13 + .../lib/ReplyBody.pb.dart | 109 +++++++ .../lib/ReplyBody.pbenum.dart | 7 + .../lib/ReplyBody.pbjson.dart | 35 +++ .../lib/ReplyBody.pbserver.dart | 9 + .../lib/ReplyBody.proto | 10 + .../lib/SentBody.pb.dart | 81 +++++ .../lib/SentBody.pbenum.dart | 7 + .../lib/SentBody.pbjson.dart | 33 ++ .../lib/SentBody.pbserver.dart | 9 + .../lib/SentBody.proto | 8 + .../lib/socket_io_connect.dart | 240 +++++++++++++++ .../cim_flutter_websocket_sdk/pubspec.yaml | 78 +++++ 64 files changed, 1559 insertions(+), 2 deletions(-) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/.flutter-plugins (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/.flutter-plugins-dependencies (94%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/.gitignore (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/.metadata (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/CHANGELOG.md (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/LICENSE (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/README.md (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/analysis_options.yaml (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/example/.gitignore (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/example/.metadata (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/example/README.md (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/example/analysis_options.yaml (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/example/lib/main.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/example/pubspec.lock (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/example/pubspec.yaml (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/Message.pb.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/Message.pbenum.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/Message.pbjson.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/Message.pbserver.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/Message.proto (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/ReplyBody.pb.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/ReplyBody.pbenum.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/ReplyBody.pbjson.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/ReplyBody.pbserver.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/ReplyBody.proto (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/SentBody.pb.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/SentBody.pbenum.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/SentBody.pbjson.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/SentBody.pbserver.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/SentBody.proto (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/lib/cim_socket.dart (100%) rename cim-client-sdk/cim-flutter-sdk/{ => cim_flutter_sdk}/pubspec.yaml (98%) create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins-dependencies create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.gitignore create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.metadata create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/CHANGELOG.md create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/LICENSE create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/README.md create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/analysis_options.yaml create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/.gitignore create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/.metadata create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/README.md create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/analysis_options.yaml create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/lib/main.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.lock create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.yaml create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pb.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbenum.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbjson.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbserver.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.proto create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pb.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbenum.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbjson.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbserver.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.proto create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pb.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbenum.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbjson.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbserver.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.proto create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/socket_io_connect.dart create mode 100644 cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/pubspec.yaml diff --git a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.flutter-plugins similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/.flutter-plugins rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.flutter-plugins diff --git a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.flutter-plugins-dependencies similarity index 94% rename from cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.flutter-plugins-dependencies index 7519b45..955ba2d 100644 --- a/cim-client-sdk/cim-flutter-sdk/.flutter-plugins-dependencies +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.flutter-plugins-dependencies @@ -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:32:14.638138","version":"3.7.7"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/.gitignore b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.gitignore similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/.gitignore rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.gitignore diff --git a/cim-client-sdk/cim-flutter-sdk/.metadata b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.metadata similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/.metadata rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.metadata diff --git a/cim-client-sdk/cim-flutter-sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/CHANGELOG.md similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/CHANGELOG.md rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/CHANGELOG.md diff --git a/cim-client-sdk/cim-flutter-sdk/LICENSE b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/LICENSE similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/LICENSE rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/LICENSE diff --git a/cim-client-sdk/cim-flutter-sdk/README.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/README.md similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/README.md rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/README.md diff --git a/cim-client-sdk/cim-flutter-sdk/analysis_options.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/analysis_options.yaml similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/analysis_options.yaml rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/analysis_options.yaml diff --git a/cim-client-sdk/cim-flutter-sdk/example/.gitignore b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/.gitignore similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/example/.gitignore rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/.gitignore diff --git a/cim-client-sdk/cim-flutter-sdk/example/.metadata b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/.metadata similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/example/.metadata rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/.metadata diff --git a/cim-client-sdk/cim-flutter-sdk/example/README.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/README.md similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/example/README.md rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/README.md diff --git a/cim-client-sdk/cim-flutter-sdk/example/analysis_options.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/analysis_options.yaml similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/example/analysis_options.yaml rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/analysis_options.yaml diff --git a/cim-client-sdk/cim-flutter-sdk/example/lib/main.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/lib/main.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/example/lib/main.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/lib/main.dart diff --git a/cim-client-sdk/cim-flutter-sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/pubspec.lock similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/example/pubspec.lock rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/pubspec.lock diff --git a/cim-client-sdk/cim-flutter-sdk/example/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/pubspec.yaml similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/example/pubspec.yaml rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/pubspec.yaml diff --git a/cim-client-sdk/cim-flutter-sdk/lib/Message.pb.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.pb.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/Message.pb.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.pb.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/Message.pbenum.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.pbenum.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/Message.pbenum.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.pbenum.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/Message.pbjson.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.pbjson.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/Message.pbjson.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.pbjson.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/Message.pbserver.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.pbserver.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/Message.pbserver.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.pbserver.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/Message.proto b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.proto similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/Message.proto rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/Message.proto diff --git a/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pb.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.pb.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pb.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.pb.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbenum.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.pbenum.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbenum.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.pbenum.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbjson.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.pbjson.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbjson.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.pbjson.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbserver.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.pbserver.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.pbserver.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.pbserver.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.proto b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.proto similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/ReplyBody.proto rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/ReplyBody.proto diff --git a/cim-client-sdk/cim-flutter-sdk/lib/SentBody.pb.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.pb.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/SentBody.pb.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.pb.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbenum.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.pbenum.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbenum.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.pbenum.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbjson.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.pbjson.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbjson.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.pbjson.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbserver.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.pbserver.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/SentBody.pbserver.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.pbserver.dart diff --git a/cim-client-sdk/cim-flutter-sdk/lib/SentBody.proto b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.proto similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/SentBody.proto rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/SentBody.proto diff --git a/cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/cim_socket.dart similarity index 100% rename from cim-client-sdk/cim-flutter-sdk/lib/cim_socket.dart rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/cim_socket.dart diff --git a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/pubspec.yaml similarity index 98% rename from cim-client-sdk/cim-flutter-sdk/pubspec.yaml rename to cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/pubspec.yaml index 227e088..89ab1c4 100644 --- a/cim-client-sdk/cim-flutter-sdk/pubspec.yaml +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/pubspec.yaml @@ -2,7 +2,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 -homepage: http://farsunset.com/ +homepage: https://farsunset.com/ environment: sdk: '>=2.19.4 <3.0.0' diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins new file mode 100644 index 0000000..cc0805d --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins @@ -0,0 +1,2 @@ +# This is a generated file; do not edit or check into version control. +device_info_plus=C:\\Users\\smeb\\AppData\\Local\\Pub\\Cache\\hosted\\pub.dev\\device_info_plus-8.2.2\\ diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins-dependencies b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins-dependencies new file mode 100644 index 0000000..b6983dc --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins-dependencies @@ -0,0 +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"} \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.gitignore b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.gitignore new file mode 100644 index 0000000..96486fd --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.gitignore @@ -0,0 +1,30 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.metadata b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.metadata new file mode 100644 index 0000000..7f104ef --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.metadata @@ -0,0 +1,27 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + channel: stable + +project_type: plugin + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/CHANGELOG.md new file mode 100644 index 0000000..d3a61b9 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +* TODO: release a primary version. only support websocket diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/LICENSE b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/LICENSE new file mode 100644 index 0000000..90d3fd9 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/LICENSE @@ -0,0 +1,25 @@ +Copyright 2023 The SDK Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/README.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/README.md new file mode 100644 index 0000000..ede011a --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/README.md @@ -0,0 +1,67 @@ +# cim_flutter_websocket_sdk + +开源通讯库 [CIM](https://gitee.com/farsunset/cim) 的 flutter版本 SDK 由于使用了 websocket 代替 Tcp长连接,额外支持了Web浏览器 + +## 长连接版本 + +[在这里](https://pub.dev/packages/cim_flutter_sdk) + + +## 如何在自己的项目中引用SDK + +在 pubspec.yaml 引入 + + +``` +dependencies: + cim_flutter_websocket_sdk: ^1.0.0 +``` + + +## 如何使用 + +``` +import 'package:cim_flutter_sdk/cim_socket.dart'; +... + + late CIMSocket? cimSocket = null; + + late List list = []; + + late String connectStatus = 'Disconnected'; + + @override + void initState() { + super.initState(); + cimSocket = CIMSocket(onMessageReceived: (value) { + setState(() { + list.add(value.toProto3Json().toString()); + }); + }, onConnectionStatusChanged: (value) { + setState(() { + connectStatus = value; + }); + }); + cimSocket!.init('127.0.0.1', 45678, '16501516154949', true); + cimSocket!.connect(); + } +... + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: Text(connectStatus), + ), + body: ListView.builder( + itemCount: list.length, + itemBuilder: (context, index) { + return Text(list[index]); + }, + ), + ), + ); + } + +``` \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/analysis_options.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/.gitignore b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/.gitignore new file mode 100644 index 0000000..24476c5 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/.gitignore @@ -0,0 +1,44 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/.metadata b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/.metadata new file mode 100644 index 0000000..8245e38 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled. + +version: + revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + channel: stable + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + - platform: web + create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/README.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/README.md new file mode 100644 index 0000000..46459d8 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/README.md @@ -0,0 +1,16 @@ +# cim_flutter_websocket_sdk_example + +Demonstrates how to use the cim_flutter_websocket_sdk plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/analysis_options.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/lib/main.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/lib/main.dart new file mode 100644 index 0000000..d863544 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/lib/main.dart @@ -0,0 +1,54 @@ +import 'package:cim_flutter_websocket_sdk/socket_io_connect.dart'; +import 'package:flutter/material.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({super.key}); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + late CIMSocket? cimSocket = null; + + late List list = []; + + late String connectStatus = 'Disconnected'; + + @override + void initState() { + super.initState(); + cimSocket = CIMSocket(onMessageReceived: (value) { + setState(() { + list.add(value.toProto3Json().toString()); + }); + }, onConnectionStatusChanged: (value) { + setState(() { + connectStatus = value; + }); + }); + cimSocket!.init('wss.hoxin.farsunset.com', 443, '16501516154949', true); + cimSocket!.connect(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: Text(connectStatus), + ), + body: ListView.builder( + itemCount: list.length, + itemBuilder: (context, index) { + return Text(list[index]); + }, + ), + ), + ); + } +} diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.lock new file mode 100644 index 0000000..9c6e17c --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.lock @@ -0,0 +1,289 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + url: "https://pub.dev" + source: hosted + version: "2.10.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + url: "https://pub.dev" + source: hosted + version: "1.2.1" + cim_flutter_websocket_sdk: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "1.0.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + url: "https://pub.dev" + source: hosted + version: "1.17.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + url: "https://pub.dev" + source: hosted + version: "1.0.5" + device_info_plus: + dependency: transitive + description: + name: device_info_plus + sha256: f52ab3b76b36ede4d135aab80194df8925b553686f0fa12226b4e2d658e45903 + url: "https://pub.dev" + source: hosted + version: "8.2.2" + device_info_plus_platform_interface: + dependency: transitive + description: + name: device_info_plus_platform_interface + sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 + url: "https://pub.dev" + source: hosted + version: "7.0.0" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + url: "https://pub.dev" + source: hosted + version: "2.0.2" + file: + dependency: transitive + description: + name: file + sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + url: "https://pub.dev" + source: hosted + version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + js: + dependency: transitive + description: + name: js + sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + url: "https://pub.dev" + source: hosted + version: "0.6.5" + matcher: + dependency: transitive + description: + name: matcher + sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + url: "https://pub.dev" + source: hosted + version: "0.12.13" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + url: "https://pub.dev" + source: hosted + version: "0.2.0" + meta: + dependency: transitive + description: + name: meta + sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" + url: "https://pub.dev" + source: hosted + version: "1.8.0" + path: + dependency: transitive + description: + name: path + sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + url: "https://pub.dev" + source: hosted + version: "1.8.2" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "01dd9bd0fa02548bf2ceee13545d4a0ec6046459d847b6b061d8a27237108a08" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + url: "https://pub.dev" + source: hosted + version: "1.9.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + url: "https://pub.dev" + source: hosted + version: "1.11.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + url: "https://pub.dev" + source: hosted + version: "0.4.16" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" + web_socket_client: + dependency: transitive + description: + name: web_socket_client + sha256: c58378b2374622c43abfb0a29dce1a9418f95e1dddbf7fdd695a8c34b01eb737 + url: "https://pub.dev" + source: hosted + version: "0.1.0-dev.3" + win32: + dependency: transitive + description: + name: win32 + sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" + url: "https://pub.dev" + source: hosted + version: "4.1.4" +sdks: + dart: ">=2.19.4 <3.0.0" + flutter: ">=2.11.0" diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.yaml new file mode 100644 index 0000000..cfd309e --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.yaml @@ -0,0 +1,82 @@ +name: cim_flutter_websocket_sdk_example +description: Demonstrates how to use the cim_flutter_websocket_sdk plugin. +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +environment: + sdk: '>=2.19.4 <3.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + + cim_flutter_websocket_sdk: + # When depending on this package from a real application you should use: + # cim_flutter_websocket_sdk: ^x.y.z + # See https://dart.dev/tools/pub/dependencies#version-constraints + # The example app is bundled with the plugin so we use a path dependency on + # the parent directory to use the current plugin's version. + path: ../ + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pb.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pb.dart new file mode 100644 index 0000000..a54c03c --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pb.dart @@ -0,0 +1,171 @@ +/// +// Generated code. Do not modify. +// source: Message.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + +import 'dart:core' as $core; + +import 'package:fixnum/fixnum.dart' as $fixnum; +import 'package:protobuf/protobuf.dart' as $pb; + +class Model extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Model', createEmptyInstance: create) + ..aInt64(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'id') + ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'action') + ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'content') + ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'sender') + ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'receiver') + ..aOS(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'extra') + ..aOS(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'title') + ..aOS(8, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'format') + ..aInt64(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'timestamp') + ..hasRequiredFields = false + ; + + Model._() : super(); + factory Model({ + $fixnum.Int64? id, + $core.String? action, + $core.String? content, + $core.String? sender, + $core.String? receiver, + $core.String? extra, + $core.String? title, + $core.String? format, + $fixnum.Int64? timestamp, + }) { + final _result = create(); + if (id != null) { + _result.id = id; + } + if (action != null) { + _result.action = action; + } + if (content != null) { + _result.content = content; + } + if (sender != null) { + _result.sender = sender; + } + if (receiver != null) { + _result.receiver = receiver; + } + if (extra != null) { + _result.extra = extra; + } + if (title != null) { + _result.title = title; + } + if (format != null) { + _result.format = format; + } + if (timestamp != null) { + _result.timestamp = timestamp; + } + return _result; + } + factory Model.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory Model.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Model clone() => Model()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Model copyWith(void Function(Model) updates) => super.copyWith((message) => updates(message as Model)) as Model; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static Model create() => Model._(); + Model createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Model getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Model? _defaultInstance; + + @$pb.TagNumber(1) + $fixnum.Int64 get id => $_getI64(0); + @$pb.TagNumber(1) + set id($fixnum.Int64 v) { $_setInt64(0, v); } + @$pb.TagNumber(1) + $core.bool hasId() => $_has(0); + @$pb.TagNumber(1) + void clearId() => clearField(1); + + @$pb.TagNumber(2) + $core.String get action => $_getSZ(1); + @$pb.TagNumber(2) + set action($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) + $core.bool hasAction() => $_has(1); + @$pb.TagNumber(2) + void clearAction() => clearField(2); + + @$pb.TagNumber(3) + $core.String get content => $_getSZ(2); + @$pb.TagNumber(3) + set content($core.String v) { $_setString(2, v); } + @$pb.TagNumber(3) + $core.bool hasContent() => $_has(2); + @$pb.TagNumber(3) + void clearContent() => clearField(3); + + @$pb.TagNumber(4) + $core.String get sender => $_getSZ(3); + @$pb.TagNumber(4) + set sender($core.String v) { $_setString(3, v); } + @$pb.TagNumber(4) + $core.bool hasSender() => $_has(3); + @$pb.TagNumber(4) + void clearSender() => clearField(4); + + @$pb.TagNumber(5) + $core.String get receiver => $_getSZ(4); + @$pb.TagNumber(5) + set receiver($core.String v) { $_setString(4, v); } + @$pb.TagNumber(5) + $core.bool hasReceiver() => $_has(4); + @$pb.TagNumber(5) + void clearReceiver() => clearField(5); + + @$pb.TagNumber(6) + $core.String get extra => $_getSZ(5); + @$pb.TagNumber(6) + set extra($core.String v) { $_setString(5, v); } + @$pb.TagNumber(6) + $core.bool hasExtra() => $_has(5); + @$pb.TagNumber(6) + void clearExtra() => clearField(6); + + @$pb.TagNumber(7) + $core.String get title => $_getSZ(6); + @$pb.TagNumber(7) + set title($core.String v) { $_setString(6, v); } + @$pb.TagNumber(7) + $core.bool hasTitle() => $_has(6); + @$pb.TagNumber(7) + void clearTitle() => clearField(7); + + @$pb.TagNumber(8) + $core.String get format => $_getSZ(7); + @$pb.TagNumber(8) + set format($core.String v) { $_setString(7, v); } + @$pb.TagNumber(8) + $core.bool hasFormat() => $_has(7); + @$pb.TagNumber(8) + void clearFormat() => clearField(8); + + @$pb.TagNumber(9) + $fixnum.Int64 get timestamp => $_getI64(8); + @$pb.TagNumber(9) + set timestamp($fixnum.Int64 v) { $_setInt64(8, v); } + @$pb.TagNumber(9) + $core.bool hasTimestamp() => $_has(8); + @$pb.TagNumber(9) + void clearTimestamp() => clearField(9); +} + diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbenum.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbenum.dart new file mode 100644 index 0000000..2655f08 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbenum.dart @@ -0,0 +1,7 @@ +/// +// Generated code. Do not modify. +// source: Message.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbjson.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbjson.dart new file mode 100644 index 0000000..37692d9 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbjson.dart @@ -0,0 +1,28 @@ +/// +// Generated code. Do not modify. +// source: Message.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package + +import 'dart:core' as $core; +import 'dart:convert' as $convert; +import 'dart:typed_data' as $typed_data; +@$core.Deprecated('Use modelDescriptor instead') +const Model$json = const { + '1': 'Model', + '2': const [ + const {'1': 'id', '3': 1, '4': 1, '5': 3, '10': 'id'}, + const {'1': 'action', '3': 2, '4': 1, '5': 9, '10': 'action'}, + const {'1': 'content', '3': 3, '4': 1, '5': 9, '10': 'content'}, + const {'1': 'sender', '3': 4, '4': 1, '5': 9, '10': 'sender'}, + const {'1': 'receiver', '3': 5, '4': 1, '5': 9, '10': 'receiver'}, + const {'1': 'extra', '3': 6, '4': 1, '5': 9, '10': 'extra'}, + const {'1': 'title', '3': 7, '4': 1, '5': 9, '10': 'title'}, + const {'1': 'format', '3': 8, '4': 1, '5': 9, '10': 'format'}, + const {'1': 'timestamp', '3': 9, '4': 1, '5': 3, '10': 'timestamp'}, + ], +}; + +/// Descriptor for `Model`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List modelDescriptor = $convert.base64Decode('CgVNb2RlbBIOCgJpZBgBIAEoA1ICaWQSFgoGYWN0aW9uGAIgASgJUgZhY3Rpb24SGAoHY29udGVudBgDIAEoCVIHY29udGVudBIWCgZzZW5kZXIYBCABKAlSBnNlbmRlchIaCghyZWNlaXZlchgFIAEoCVIIcmVjZWl2ZXISFAoFZXh0cmEYBiABKAlSBWV4dHJhEhQKBXRpdGxlGAcgASgJUgV0aXRsZRIWCgZmb3JtYXQYCCABKAlSBmZvcm1hdBIcCgl0aW1lc3RhbXAYCSABKANSCXRpbWVzdGFtcA=='); diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbserver.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbserver.dart new file mode 100644 index 0000000..6b8edd0 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.pbserver.dart @@ -0,0 +1,9 @@ +/// +// Generated code. Do not modify. +// source: Message.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package + +export 'Message.pb.dart'; + diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.proto b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.proto new file mode 100644 index 0000000..2b8c058 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/Message.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +message Model { + int64 id = 1; + string action = 2; + string content = 3; + string sender = 4; + string receiver = 5; + string extra = 6; + string title = 7; + string format = 8; + int64 timestamp = 9; +} + \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pb.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pb.dart new file mode 100644 index 0000000..dd76bb2 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pb.dart @@ -0,0 +1,109 @@ +/// +// Generated code. Do not modify. +// source: ReplyBody.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + +import 'dart:core' as $core; + +import 'package:fixnum/fixnum.dart' as $fixnum; +import 'package:protobuf/protobuf.dart' as $pb; + +class Model extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Model', createEmptyInstance: create) + ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key') + ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'code') + ..aOS(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'message') + ..aInt64(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'timestamp') + ..m<$core.String, $core.String>(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data', entryClassName: 'Model.DataEntry', keyFieldType: $pb.PbFieldType.OS, valueFieldType: $pb.PbFieldType.OS) + ..hasRequiredFields = false + ; + + Model._() : super(); + factory Model({ + $core.String? key, + $core.String? code, + $core.String? message, + $fixnum.Int64? timestamp, + $core.Map<$core.String, $core.String>? data, + }) { + final _result = create(); + if (key != null) { + _result.key = key; + } + if (code != null) { + _result.code = code; + } + if (message != null) { + _result.message = message; + } + if (timestamp != null) { + _result.timestamp = timestamp; + } + if (data != null) { + _result.data.addAll(data); + } + return _result; + } + factory Model.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory Model.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Model clone() => Model()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Model copyWith(void Function(Model) updates) => super.copyWith((message) => updates(message as Model)) as Model; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static Model create() => Model._(); + Model createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Model getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Model? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get key => $_getSZ(0); + @$pb.TagNumber(1) + set key($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasKey() => $_has(0); + @$pb.TagNumber(1) + void clearKey() => clearField(1); + + @$pb.TagNumber(2) + $core.String get code => $_getSZ(1); + @$pb.TagNumber(2) + set code($core.String v) { $_setString(1, v); } + @$pb.TagNumber(2) + $core.bool hasCode() => $_has(1); + @$pb.TagNumber(2) + void clearCode() => clearField(2); + + @$pb.TagNumber(3) + $core.String get message => $_getSZ(2); + @$pb.TagNumber(3) + set message($core.String v) { $_setString(2, v); } + @$pb.TagNumber(3) + $core.bool hasMessage() => $_has(2); + @$pb.TagNumber(3) + void clearMessage() => clearField(3); + + @$pb.TagNumber(4) + $fixnum.Int64 get timestamp => $_getI64(3); + @$pb.TagNumber(4) + set timestamp($fixnum.Int64 v) { $_setInt64(3, v); } + @$pb.TagNumber(4) + $core.bool hasTimestamp() => $_has(3); + @$pb.TagNumber(4) + void clearTimestamp() => clearField(4); + + @$pb.TagNumber(5) + $core.Map<$core.String, $core.String> get data => $_getMap(4); +} + diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbenum.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbenum.dart new file mode 100644 index 0000000..90a3c89 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbenum.dart @@ -0,0 +1,7 @@ +/// +// Generated code. Do not modify. +// source: ReplyBody.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbjson.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbjson.dart new file mode 100644 index 0000000..e3eed00 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbjson.dart @@ -0,0 +1,35 @@ +/// +// Generated code. Do not modify. +// source: ReplyBody.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package + +import 'dart:core' as $core; +import 'dart:convert' as $convert; +import 'dart:typed_data' as $typed_data; +@$core.Deprecated('Use modelDescriptor instead') +const Model$json = const { + '1': 'Model', + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const {'1': 'code', '3': 2, '4': 1, '5': 9, '10': 'code'}, + const {'1': 'message', '3': 3, '4': 1, '5': 9, '10': 'message'}, + const {'1': 'timestamp', '3': 4, '4': 1, '5': 3, '10': 'timestamp'}, + const {'1': 'data', '3': 5, '4': 3, '5': 11, '6': '.Model.DataEntry', '10': 'data'}, + ], + '3': const [Model_DataEntry$json], +}; + +@$core.Deprecated('Use modelDescriptor instead') +const Model_DataEntry$json = const { + '1': 'DataEntry', + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, + ], + '7': const {'7': true}, +}; + +/// Descriptor for `Model`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List modelDescriptor = $convert.base64Decode('CgVNb2RlbBIQCgNrZXkYASABKAlSA2tleRISCgRjb2RlGAIgASgJUgRjb2RlEhgKB21lc3NhZ2UYAyABKAlSB21lc3NhZ2USHAoJdGltZXN0YW1wGAQgASgDUgl0aW1lc3RhbXASJAoEZGF0YRgFIAMoCzIQLk1vZGVsLkRhdGFFbnRyeVIEZGF0YRo3CglEYXRhRW50cnkSEAoDa2V5GAEgASgJUgNrZXkSFAoFdmFsdWUYAiABKAlSBXZhbHVlOgI4AQ=='); diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbserver.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbserver.dart new file mode 100644 index 0000000..2ad6b02 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.pbserver.dart @@ -0,0 +1,9 @@ +/// +// Generated code. Do not modify. +// source: ReplyBody.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package + +export 'ReplyBody.pb.dart'; + diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.proto b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.proto new file mode 100644 index 0000000..871a511 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/ReplyBody.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +message Model { + string key = 1; + string code = 2; + string message = 3; + int64 timestamp =4; + map data =5; + +} + \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pb.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pb.dart new file mode 100644 index 0000000..780f730 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pb.dart @@ -0,0 +1,81 @@ +/// +// Generated code. Do not modify. +// source: SentBody.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + +import 'dart:core' as $core; + +import 'package:fixnum/fixnum.dart' as $fixnum; +import 'package:protobuf/protobuf.dart' as $pb; + +class Model extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Model', createEmptyInstance: create) + ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'key') + ..aInt64(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'timestamp') + ..m<$core.String, $core.String>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'data', entryClassName: 'Model.DataEntry', keyFieldType: $pb.PbFieldType.OS, valueFieldType: $pb.PbFieldType.OS) + ..hasRequiredFields = false + ; + + Model._() : super(); + factory Model({ + $core.String? key, + $fixnum.Int64? timestamp, + $core.Map<$core.String, $core.String>? data, + }) { + final _result = create(); + if (key != null) { + _result.key = key; + } + if (timestamp != null) { + _result.timestamp = timestamp; + } + if (data != null) { + _result.data.addAll(data); + } + return _result; + } + factory Model.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory Model.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Model clone() => Model()..mergeFromMessage(this); + @$core.Deprecated( + 'Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Model copyWith(void Function(Model) updates) => super.copyWith((message) => updates(message as Model)) as Model; // ignore: deprecated_member_use + $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') + static Model create() => Model._(); + Model createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Model getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Model? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get key => $_getSZ(0); + @$pb.TagNumber(1) + set key($core.String v) { $_setString(0, v); } + @$pb.TagNumber(1) + $core.bool hasKey() => $_has(0); + @$pb.TagNumber(1) + void clearKey() => clearField(1); + + @$pb.TagNumber(2) + $fixnum.Int64 get timestamp => $_getI64(1); + @$pb.TagNumber(2) + set timestamp($fixnum.Int64 v) { $_setInt64(1, v); } + @$pb.TagNumber(2) + $core.bool hasTimestamp() => $_has(1); + @$pb.TagNumber(2) + void clearTimestamp() => clearField(2); + + @$pb.TagNumber(3) + $core.Map<$core.String, $core.String> get data => $_getMap(2); +} + diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbenum.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbenum.dart new file mode 100644 index 0000000..e9631c3 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbenum.dart @@ -0,0 +1,7 @@ +/// +// Generated code. Do not modify. +// source: SentBody.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields + diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbjson.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbjson.dart new file mode 100644 index 0000000..a22098b --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbjson.dart @@ -0,0 +1,33 @@ +/// +// Generated code. Do not modify. +// source: SentBody.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package + +import 'dart:core' as $core; +import 'dart:convert' as $convert; +import 'dart:typed_data' as $typed_data; +@$core.Deprecated('Use modelDescriptor instead') +const Model$json = const { + '1': 'Model', + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const {'1': 'timestamp', '3': 2, '4': 1, '5': 3, '10': 'timestamp'}, + const {'1': 'data', '3': 3, '4': 3, '5': 11, '6': '.Model.DataEntry', '10': 'data'}, + ], + '3': const [Model_DataEntry$json], +}; + +@$core.Deprecated('Use modelDescriptor instead') +const Model_DataEntry$json = const { + '1': 'DataEntry', + '2': const [ + const {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + const {'1': 'value', '3': 2, '4': 1, '5': 9, '10': 'value'}, + ], + '7': const {'7': true}, +}; + +/// Descriptor for `Model`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List modelDescriptor = $convert.base64Decode('CgVNb2RlbBIQCgNrZXkYASABKAlSA2tleRIcCgl0aW1lc3RhbXAYAiABKANSCXRpbWVzdGFtcBIkCgRkYXRhGAMgAygLMhAuTW9kZWwuRGF0YUVudHJ5UgRkYXRhGjcKCURhdGFFbnRyeRIQCgNrZXkYASABKAlSA2tleRIUCgV2YWx1ZRgCIAEoCVIFdmFsdWU6AjgB'); diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbserver.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbserver.dart new file mode 100644 index 0000000..bba2612 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.pbserver.dart @@ -0,0 +1,9 @@ +/// +// Generated code. Do not modify. +// source: SentBody.proto +// +// @dart = 2.12 +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package + +export 'SentBody.pb.dart'; + diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.proto b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.proto new file mode 100644 index 0000000..5a1f93c --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/SentBody.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +message Model { + string key = 1; + int64 timestamp =2; + map data =3; + +} + \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/socket_io_connect.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/socket_io_connect.dart new file mode 100644 index 0000000..6226e94 --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/socket_io_connect.dart @@ -0,0 +1,240 @@ +import 'dart:convert'; +import 'dart:io'; +import 'package:crypto/crypto.dart'; +import 'package:device_info_plus/device_info_plus.dart'; +import 'package:flutter/foundation.dart'; + +import './Message.pb.dart' as messages; +import './ReplyBody.pb.dart' as replybody; +import './SentBody.pb.dart' as sentbody; +import 'package:fixnum/fixnum.dart'; +import 'package:convert/convert.dart'; + +// ignore_for_file: avoid_print +import 'package:web_socket_client/web_socket_client.dart'; + +//PONG +// ignore: constant_identifier_names +const PONG_TYPE = 0; +//发送消息类型 +// ignore: constant_identifier_names +const Message_TYPE = 2; +//强制下线类型 +// ignore: constant_identifier_names +const ACTION_999 = 999; +//响应消息类型 +// ignore: constant_identifier_names +const REPLY_BODY = 4; +//消息发送 +// ignore: constant_identifier_names +const SEND_BODY = 3; +//PING +// ignore: constant_identifier_names +const PING_TYPE = 1; + +// ignore: constant_identifier_names +const DATA_HEADER_LENGTH = 1; + +const sOCKETAPPVERSION = '100'; + +class CIMSocket { + CIMSocket( + {required this.onMessageReceived, + required this.onConnectionStatusChanged}); + + /// 句柄 + late WebSocket? channel; + + /// 地址 + late String? uri; + + /// 端口 + late int? port; + + /// 用户id + late String? uid; + + /// + late String endCode = "0"; + + /// 是否使用SSL + late bool useSsl = false; + + /// 设备信息 + final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); + + /// 消息回调 + final ValueChanged onMessageReceived; + + /// 连接状态回调 + final ValueChanged onConnectionStatusChanged; + + /// + /// [uri] 地址 + /// [port] 端口 + /// [uid] 用户id + /// [useSsl] 是否使用ssl + Future init(String uri, int port, String uid, bool useSsl) async { + this.uri = uri; + this.port = port; + this.uid = uid; + this.useSsl = useSsl; + } + + //登录 + Future connect() async { + if (uri == null || port == null || uid == null) { + throw IOException; + } + + channel = WebSocket(Uri.parse('${useSsl ? 'wss' : 'ws'}://$uri:$port'), + backoff: ConstantBackoff(Duration(seconds: 10)), + binaryType: 'arraybuffer'); + + channel!.connection.listen((event) { + if (event.runtimeType == Connected || event.runtimeType == Reconnected) { + sendLoginMsg(); + onConnectionStatusChanged( + event.runtimeType == Connected ? 'Connected' : 'Reconnected'); + } else { + onConnectionStatusChanged(event.runtimeType.toString()); + } + }); + + channel!.messages.listen((message) { + Uint8List data = message; + if (data[0] == PING_TYPE) { + sendPong(); + } else if (data[0] == REPLY_BODY) { + 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) { + channel = null; + onConnectionStatusChanged('Disconnected'); + }, onDone: () { + channel = null; + onConnectionStatusChanged('Disconnected'); + }, cancelOnError: true); + } + + //登出 + Future disConnect() async { + if (channel != null) { + endCode = '999'; + channel!.close(); + } + } + + //发送登录消息 + Future sendLoginMsg() async { + SystemInfo systemInfo = SystemInfo(); + await systemInfo.init(); + String 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); + + Map map = { + "uid": uid!, //主id + "channel": channelName, + "appVersion": sOCKETAPPVERSION, + "osVersion": systemVersion, + "packageName": "cn.asihe.cim", + "deviceId": deviceId, + // (await PlatformDeviceId.getDeviceId)!.replaceAll("-", ""), //应用id + "deviceName": '$deviceName ${systemInfo.model}', + "language": "zh-CN", + }; + int time = DateTime.now().millisecondsSinceEpoch; + Int64 timeStamp = Int64.parseInt(time.toString()); + var body = sentbody.Model(data: map); + body.key = "client_bind"; + body.timestamp = timeStamp; + var data = body.writeToBuffer(); + var protobuf = Uint8List(data.length + 1); + protobuf[0] = 3; + protobuf.setRange(1, data.length + 1, data); + channel!.send(protobuf); + } + +//发送PONG响应 + Future sendPong() async { + var pONGBODY = Uint8List(4); + var pONG = Uint8List(pONGBODY.length + 1); + pONGBODY[0] = 80; + pONGBODY[1] = 79; + pONGBODY[2] = 78; + pONGBODY[3] = 71; + pONG[0] = 0; + pONG.setRange(1, 4, pONGBODY); + channel!.send(pONG); + } +} + +class SystemInfo { + String deviceName = 'cim_entity'; + String version = '0.0.1'; + String deviceId = 'CIM Entity'; + String model = "10"; + final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); + + Future init() async { + if (kIsWeb) { + var value = await deviceInfoPlugin.webBrowserInfo; + deviceName = "web"; + version = value.appVersion!.substring(0, 6); + deviceId = value.appCodeName!; + model = value.browserName.name; + return; + } + + if (Platform.isAndroid) { + // Android相关代码 + var value = await deviceInfoPlugin.androidInfo; + deviceName = 'android'; + version = Platform.version.substring(0, 6); + deviceId = value.id; + model = value.model; + } else if (Platform.isIOS) { + // iOS相关代码 + var value = await deviceInfoPlugin.iosInfo; + deviceName = 'ios'; + version = Platform.version.substring(0, 6); + deviceId = value.identifierForVendor!; + model = value.model!; + } else if (Platform.isMacOS) { + // MacOS相关代码 + var value = await deviceInfoPlugin.macOsInfo; + + deviceName = 'mac'; + version = Platform.version.substring(0, 6); + deviceId = value.model; + model = value.model; + } else if (Platform.isWindows) { + // Windows相关代码 + var value = await deviceInfoPlugin.windowsInfo; + deviceName = 'windows'; + version = Platform.version.substring(0, 6); + deviceId = value.deviceId; + model = value.majorVersion.toString(); + } else if (Platform.isLinux) { + // Linux相关代码 + var value = await deviceInfoPlugin.linuxInfo; + deviceName = 'linux'; + version = Platform.version.substring(0, 6); + deviceId = value.id; + model = value.version!; + } + } +} diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/pubspec.yaml new file mode 100644 index 0000000..2e6d1ee --- /dev/null +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/pubspec.yaml @@ -0,0 +1,78 @@ +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 +homepage: http://farsunset.com/ + +environment: + sdk: '>=2.19.4 <3.0.0' + flutter: '>=2.5.0' + +dependencies: + flutter: + sdk: flutter + protobuf: ^2.0.1 # Google protobuf 序列化 + device_info_plus: ^8.2.2 + crypto: ^3.0.3 + convert: ^3.1.1 + fixnum: ^1.1.0 + web_socket_client: ^0.1.0-dev.3 + +dev_dependencies: + flutter_test: + sdk: flutter +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +#flutter: +# This section identifies this Flutter project as a plugin project. +# The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.) +# which should be registered in the plugin registry. This is required for +# using method channels. +# The Android 'package' specifies package in which the registered class is. +# This is required for using method channels on Android. +# The 'ffiPlugin' specifies that native code should be built and bundled. +# This is required for using `dart:ffi`. +# All these are used by the tooling to maintain consistency when +# adding or updating assets for this project. +#plugin: +# platforms: +# This plugin project was generated without specifying any +# platforms with the `--platform` argument. If you see the `some_platform` map below, remove it and +# then add platforms following the instruction here: +# https://flutter.dev/docs/development/packages-and-plugins/developing-packages#plugin-platforms +# ------------------- +# some_platform: +# pluginClass: somePluginClass +# ------------------- + +# To add assets to your plugin package, add an assets section, like this: +# assets: +# - images/a_dot_burr.jpeg +# - images/a_dot_ham.jpeg +# +# For details regarding assets in packages, see +# https://flutter.dev/assets-and-images/#from-packages +# +# An image asset can refer to one or more resolution-specific "variants", see +# https://flutter.dev/assets-and-images/#resolution-aware + +# To add custom fonts to your plugin package, add a fonts section here, +# in this "flutter" section. Each entry in this list should have a +# "family" key with the font family name, and a "fonts" key with a +# list giving the asset and other descriptors for the font. For +# example: +# fonts: +# - family: Schyler +# fonts: +# - asset: fonts/Schyler-Regular.ttf +# - asset: fonts/Schyler-Italic.ttf +# style: italic +# - family: Trajan Pro +# fonts: +# - asset: fonts/TrajanPro.ttf +# - asset: fonts/TrajanPro_Bold.ttf +# weight: 700 +# +# For details regarding fonts in packages, see +# https://flutter.dev/custom-fonts/#from-packages From 37bb7a06bc503223e50110fed5bdfdc0728f315b Mon Sep 17 00:00:00 2001 From: yangjiejie12308 <38904385+yangjiejie12308@users.noreply.github.com> Date: Mon, 17 Jul 2023 09:32:34 +0800 Subject: [PATCH 12/12] =?UTF-8?q?flutter=20sdk=20=E9=95=BF=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E7=99=BB=E5=BD=95=E4=BF=A1=E6=81=AF=20=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E7=BC=BA=E7=9C=81=E5=8F=82=E6=95=B0=20=E5=8F=AF?= =?UTF-8?q?=E8=87=AA=E8=A1=8C=E5=A1=AB=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.flutter-plugins-dependencies | 2 +- .../cim_flutter_sdk/CHANGELOG.md | 4 +- .../cim-flutter-sdk/cim_flutter_sdk/README.md | 10 ++- .../cim_flutter_sdk/example/.metadata | 2 +- .../cim_flutter_sdk/example/lib/main.dart | 11 +-- .../cim_flutter_sdk/example/pubspec.lock | 2 +- .../cim_flutter_sdk/lib/cim_socket.dart | 49 ++++++++++--- .../cim_flutter_sdk/pubspec.yaml | 2 +- .../.flutter-plugins-dependencies | 2 +- .../cim_flutter_websocket_sdk/CHANGELOG.md | 4 +- .../cim_flutter_websocket_sdk/README.md | 11 ++- .../example/lib/main.dart | 9 ++- .../example/pubspec.lock | 2 +- .../lib/socket_io_connect.dart | 70 +++++++++++++++---- .../cim_flutter_websocket_sdk/pubspec.yaml | 2 +- 15 files changed, 140 insertions(+), 42 deletions(-) diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.flutter-plugins-dependencies b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.flutter-plugins-dependencies index 955ba2d..743a6c2 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.flutter-plugins-dependencies +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/.flutter-plugins-dependencies @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/CHANGELOG.md index 34cfda1..143cf82 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/CHANGELOG.md +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/CHANGELOG.md @@ -1,3 +1,3 @@ -## 1.0.5 +## 1.0.6 -* allow connect string uid type are string. update readme.md +* allow Custom login parameters. diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/README.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/README.md index ffc5859..702b06b 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/README.md @@ -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"); } ... diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/.metadata b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/.metadata index 8245e38..b1fefbe 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/.metadata +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/.metadata @@ -15,7 +15,7 @@ migration: - platform: root create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da - - platform: web + - platform: windows create_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da base_revision: 2ad6cd72c040113b47ee9055e722606a490ef0da diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/lib/main.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/lib/main.dart index a67cbba..9ad42e0 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/lib/main.dart +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/lib/main.dart @@ -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 { }); }); 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 diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/pubspec.lock index eede5ce..ada1e8b 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/pubspec.lock +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/example/pubspec.lock @@ -31,7 +31,7 @@ packages: path: ".." relative: true source: path - version: "1.0.5" + version: "1.0.6" clock: dependency: transitive description: diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/cim_socket.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/cim_socket.dart index 1df90c0..6018c97 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/cim_socket.dart +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/lib/cim_socket.dart @@ -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 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()); diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/pubspec.yaml index 89ab1c4..2f36074 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/pubspec.yaml +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_sdk/pubspec.yaml @@ -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: diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins-dependencies b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins-dependencies index b6983dc..9686087 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins-dependencies +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/.flutter-plugins-dependencies @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/CHANGELOG.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/CHANGELOG.md index d3a61b9..6249f3c 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/CHANGELOG.md +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/CHANGELOG.md @@ -1,3 +1,3 @@ -## 1.0.0 +## 1.0.1 -* TODO: release a primary version. only support websocket +* allow Custom login parameters. diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/README.md b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/README.md index ede011a..35a42b3 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/README.md +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/README.md @@ -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"); } ... diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/lib/main.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/lib/main.dart index d863544..6209637 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/lib/main.dart +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/lib/main.dart @@ -32,7 +32,14 @@ class _MyAppState extends State { }); }); 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 diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.lock b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.lock index 9c6e17c..c437ab0 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.lock +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/example/pubspec.lock @@ -31,7 +31,7 @@ packages: path: ".." relative: true source: path - version: "1.0.0" + version: "1.0.1" clock: dependency: transitive description: diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/socket_io_connect.dart b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/socket_io_connect.dart index 6226e94..52d21ea 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/socket_io_connect.dart +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/lib/socket_io_connect.dart @@ -69,6 +69,27 @@ class CIMSocket { /// 连接状态回调 final ValueChanged 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 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()); diff --git a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/pubspec.yaml b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/pubspec.yaml index 2e6d1ee..4e50449 100644 --- a/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/pubspec.yaml +++ b/cim-client-sdk/cim-flutter-sdk/cim_flutter_websocket_sdk/pubspec.yaml @@ -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: