Skip to content

Commit

Permalink
Update CourierProtobuf readme and license
Browse files Browse the repository at this point in the history
  • Loading branch information
alfianlosari committed Jul 14, 2023
1 parent 2dc68a9 commit 6aa09e1
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 26 deletions.
22 changes: 21 additions & 1 deletion courier_protobuf/LICENSE
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
TODO: Add your license here.
MIT License

Copyright (c) 2023 GO-JEK Tech

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.
67 changes: 42 additions & 25 deletions courier_protobuf/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,56 @@
<!--
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.
# courier_protobuf

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).
Courier Protobuf MessageAdater for Courier Dart SDK

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).
-->
## Getting Started

TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.
Run this command:

## Features
With Flutter:

TODO: List what your package can do. Maybe include images, gifs, or videos.
```shell
$ flutter pub add courier_protobuf
```

## Getting started
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

TODO: List prerequisites and provide or point to information on how to
start using the package.
```yaml
dependencies:
courier_protobuf: 0.0.1
```
## Usage
You can use this package along with courier_dart_sdk if you want to use Protobuf as MesageAdapter for your CourierClient.
TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.
```dart
final CourierClient courierClient = CourierClient.create(
...
messageAdapters: const <MessageAdapter>[
ProtobufMessageAdapter(),
...
])
);
```

Decode bytes to Pet.pb GeneratedMessage:

```dart
const like = 'sample';
courierClient
.courierMessageStream<Pet>(
"pet/6b57d4e5-0fce-4917-b343-c8a1c77405e5/update",
decoder: Pet.fromBuffer)
.listen((pet) {
print("Message received Pet: ${pet.name}");
});
```

## Additional information
Encode Pet GeneratedMessage pb to bytes:

```dart
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.
final pet = Pet();
pet.name = "Hello Pet";
courierClient.publishCourierMessage(CourierMessage(
payload: pet,
topic: "pet/6b57d4e5-0fce-4917-b343-c8a1c77405e5/update",
qos: QoS.one));
```

0 comments on commit 6aa09e1

Please sign in to comment.