新增 flutter_websocket_sdk 支持所有平台

This commit is contained in:
yangjiejie12308 2023-07-14 11:22:34 +08:00
parent 2a3d315d75
commit df3385151a
64 changed files with 1559 additions and 2 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,3 @@
## 1.0.0
* TODO: release a primary version. only support websocket

View File

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

View File

@ -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<String> 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]);
},
),
),
);
}
```

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late CIMSocket? cimSocket = null;
late List<String> 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]);
},
),
),
);
}
}

View File

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

View File

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

View File

@ -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<Model> createRepeated() => $pb.PbList<Model>();
@$core.pragma('dart2js:noInline')
static Model getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Model>(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);
}

View File

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

View File

@ -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==');

View File

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

View File

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

View File

@ -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<Model> createRepeated() => $pb.PbList<Model>();
@$core.pragma('dart2js:noInline')
static Model getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Model>(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);
}

View File

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

View File

@ -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==');

View File

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

View File

@ -0,0 +1,10 @@
syntax = "proto3";
message Model {
string key = 1;
string code = 2;
string message = 3;
int64 timestamp =4;
map<string,string> data =5;
}

View File

@ -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<Model> createRepeated() => $pb.PbList<Model>();
@$core.pragma('dart2js:noInline')
static Model getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Model>(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);
}

View File

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

View File

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

View File

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

View File

@ -0,0 +1,8 @@
syntax = "proto3";
message Model {
string key = 1;
int64 timestamp =2;
map<string,string> data =3;
}

View File

@ -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<messages.Model> onMessageReceived;
///
final ValueChanged<String> 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<String, String> 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!;
}
}
}

View File

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