-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from RikitoNoto/release/1.1.0
Release/1.1.0
- Loading branch information
Showing
30 changed files
with
3,377 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: flutter test | ||
|
||
on: | ||
pull_request: | ||
branches: [ "main", "develop" ] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: dart-lang/setup-dart@v1 | ||
with: | ||
sdk: 3.10.4 | ||
|
||
- uses: subosito/[email protected] | ||
with: | ||
flutter-version: '3.10.3' | ||
|
||
- name: Install dependencies | ||
run: flutter pub get | ||
|
||
- name: Analyze project source | ||
run: flutter analyze | ||
|
||
- name: Run tests | ||
run: flutter test --exclude-tags UseNetwork |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ migrate_working_dir/ | |
.dart_tool/ | ||
.packages | ||
build/ | ||
|
||
.fvm/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
## 0.0.1 | ||
|
||
* TODO: Describe initial release. | ||
## 1.0.0 | ||
create initial release. | ||
## 1.1.0 | ||
Changed the import file to be only camel.dart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
TODO: Add your license here. | ||
MIT License | ||
|
||
Copyright (c) 2023 RikitoNoto | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,100 @@ | ||
<!-- | ||
This README describes the package. If you publish this package to pub.dev, | ||
this README's contents appear on the landing page for your package. | ||
# Camel | ||
[日本語](doc/README.jp.md)<br/> | ||
|
||
For information about how to write a good package README, see the guide for | ||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages). | ||
For general information about developing packages, see the Dart guide for | ||
[creating packages](https://dart.dev/guides/libraries/create-library-packages) | ||
and the Flutter guide for | ||
[developing packages and plugins](https://flutter.dev/developing-packages). | ||
--> | ||
|
||
TODO: Put a short description of the package here that helps potential users | ||
know whether this package might be useful for them. | ||
Flutter package that allows communicating in a local network. | ||
|
||
## Features | ||
|
||
TODO: List what your package can do. Maybe include images, gifs, or videos. | ||
This library allows you to communicate in a local network without "dart:io" package. | ||
Also, you can switch callback communication or stream communication. | ||
|
||
## Getting started | ||
Add this package to your pubspec.yaml | ||
```yaml | ||
# pubspec.yaml | ||
|
||
TODO: List prerequisites and provide or point to information on how to | ||
start using the package. | ||
dependencies: | ||
camel: ^<latest version> | ||
``` | ||
## Usage | ||
TODO: Include short and useful examples for package users. Add longer examples | ||
to `/example` folder. | ||
### Sender | ||
If the receiver doesn't use a command callback, you call the send method as below. | ||
```dart | ||
// if you use socket communication and TCP. | ||
final Communicator communicator = Tcp(); | ||
final Camel<Socket, SocketConnectionPoint> sender = Camel(communicator); | ||
|
||
// call send method with a connection point a send message. | ||
sender.send( | ||
SocketConnectionPoint(address: "127.0.0.1", port: 50000), | ||
Message.fromBody(command: "dummy", body: "Hello, Camel."), | ||
); | ||
``` | ||
|
||
When using a command callback, you define a custom command class as below. | ||
```dart | ||
const like = 'sample'; | ||
class MyCommand implements Command { | ||
@override String get command => "MY_COMMAND"; | ||
@override | ||
void execute(Uint8List data){ | ||
// This method is called when data is received by the Camel.listen method. | ||
print("received: ${utf8.decode(data)}"); // received: Hello, Camel. | ||
} | ||
} | ||
// if you use socket communication and TCP. | ||
final Communicator communicator = Tcp(); | ||
final Camel<Socket, SocketConnectionPoint> sender = Camel(communicator); | ||
CommandFactory.registerCommand(MyCommand()); // register command. | ||
// call send method with a connection point a send message. | ||
sender.send( | ||
SocketConnectionPoint(address: "127.0.0.1", port: 50000), | ||
Message.fromBody(command: "MY_COMMAND", body: "Hello, Camel."), | ||
); | ||
``` | ||
|
||
## Additional information | ||
### Receiver | ||
If the receiver doesn't use callback, you can call the listen method as below. | ||
```dart | ||
// if you use socket communication and TCP. | ||
final Communicator communicator = Tcp(); | ||
final Camel<Socket, SocketConnectionPoint> receiver = Camel(communicator); | ||
// call listen method with a bind connection point. | ||
await for( | ||
CommunicateData<Socket> data in receiver.listen( | ||
SocketConnectionPoint(address: "127.0.0.1", port: 50000) | ||
) | ||
){ | ||
print(data.message.body); // display received data. | ||
} | ||
``` | ||
|
||
When the receiver receives the custom command, then call the execute method of the command as below. | ||
```dart | ||
class MyCommand implements Command { | ||
@override String get command => "MY_COMMAND"; | ||
@override | ||
void execute(Uint8List data){ | ||
// This method is called when data is received by the Camel.listen method. | ||
print("received: ${utf8.decode(data)}"); // display "received: " + received data | ||
} | ||
} | ||
// if you use socket communication and TCP. | ||
final Communicator communicator = Tcp(); | ||
final Camel<Socket, SocketConnectionPoint> receiver = Camel(communicator); | ||
CommandFactory.registerCommand(MyCommand()); // register command. | ||
// call listen method with a bind connection point. | ||
await for( | ||
CommunicateData<Socket> _ in receiver.listen( | ||
SocketConnectionPoint(address: "127.0.0.1", port: 50000) | ||
) | ||
){} | ||
``` | ||
|
||
TODO: Tell users more about the package: where to find more information, how to | ||
contribute to the package, how to file issues, what response they can expect | ||
from the package authors, and more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sdk.dir=C:\\Users\\R.NOTO\\AppData\\Local\\Android\\sdk | ||
flutter.sdk=C:\\Users\\R.NOTO\\fvm\\versions\\3.10.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
# Camel | ||
[English](../README.md)<br/> | ||
|
||
ローカルネットワークで通信を行うためのFlutterパッケージ。 | ||
|
||
## 特徴 | ||
このライブラリは"dart:io"ライブラリを使わず、簡単にローカルネットワーク通信を行えます。 | ||
また、受信データはコールバックかStreamを使用した形式か選択して使用することができます。 | ||
|
||
## インストール | ||
このパッケージをpubspec.yamlに追加してください。 | ||
```yaml | ||
# pubspec.yaml | ||
|
||
dependencies: | ||
camel: ^<latest version> | ||
``` | ||
## 使用方法 | ||
### 送信側 | ||
受信側がCommandクラスのコールバック処理を使用しない場合は、以下のように送信処理を作成できます。 | ||
```dart | ||
// TCPを使用したSocket通信を行う場合。 | ||
final Communicator communicator = Tcp(); | ||
final Camel<Socket, SocketConnectionPoint> sender = Camel(communicator); | ||
|
||
// コネクションポイントと送信データを渡してsendメソッドを呼び出しします。 | ||
sender.send( | ||
SocketConnectionPoint(address: "127.0.0.1", port: 50000), | ||
Message.fromBody(command: "dummy", body: "Hello, Camel."), | ||
); | ||
``` | ||
|
||
受信側がCommandクラスのコールバック処理を使用する場合は、以下のようにします。 | ||
```dart | ||
class MyCommand implements Command { | ||
@override String get command => "MY_COMMAND"; | ||
@override | ||
void execute(Uint8List data){ | ||
// このメソッドは受信側がデータを受信したときに呼び出されます。 | ||
print("received: ${utf8.decode(data)}"); // received: Hello, Camel. | ||
} | ||
} | ||
// TCPを使用したSocket通信を行う場合。 | ||
final Communicator communicator = Tcp(); | ||
final Camel<Socket, SocketConnectionPoint> sender = Camel(communicator); | ||
CommandFactory.registerCommand(MyCommand()); // 作成したコマンドの登録 | ||
// コネクションポイントと送信データを渡してsendメソッドを呼び出しします。 | ||
// この時、作成したコマンドの名前をcommand引数に渡します。 | ||
sender.send( | ||
SocketConnectionPoint(address: "127.0.0.1", port: 50000), | ||
Message.fromBody(command: "MY_COMMAND", body: "Hello, Camel."), | ||
); | ||
``` | ||
|
||
### 受信側 | ||
受信側がCommandクラスのコールバック処理を使用しない場合は、以下のように受信処理を作成できます。 | ||
```dart | ||
// TCPを使用したSocket通信を行う場合。 | ||
final Communicator communicator = Tcp(); | ||
final Camel<Socket, SocketConnectionPoint> receiver = Camel(communicator); | ||
// バインドするコネクションポイントとともにlistenメソッドを呼び出します。 | ||
await for( | ||
CommunicateData<Socket> data in receiver.listen( | ||
SocketConnectionPoint(address: "127.0.0.1", port: 50000) | ||
) | ||
){ | ||
print(data.message.body); // Streamとしてデータを受信します。 | ||
} | ||
``` | ||
|
||
|
||
受信側がCommandクラスのコールバック処理を使用する場合は、以下のようにします。 | ||
|
||
```dart | ||
class MyCommand implements Command { | ||
@override String get command => "MY_COMMAND"; | ||
@override | ||
void execute(Uint8List data){ | ||
// このメソッドは受信側がデータを受信したときに呼び出されます。 | ||
print("received: ${utf8.decode(data)}"); | ||
} | ||
} | ||
// TCPを使用したSocket通信を行う場合。 | ||
final Communicator communicator = Tcp(); | ||
final Camel<Socket, SocketConnectionPoint> receiver = Camel(communicator); | ||
// バインドするコネクションポイントとともにlistenメソッドを呼び出します。 | ||
await for( | ||
CommunicateData<Socket> _ in receiver.listen( | ||
SocketConnectionPoint(address: "127.0.0.1", port: 50000) | ||
) | ||
){} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.