From 6aa09e1663ae73abfe83fe8794ebe787e24fd86c Mon Sep 17 00:00:00 2001 From: Alfian Losari Date: Fri, 14 Jul 2023 17:56:53 +0700 Subject: [PATCH] Update CourierProtobuf readme and license --- courier_protobuf/LICENSE | 22 ++++++++++++- courier_protobuf/README.md | 67 ++++++++++++++++++++++++-------------- 2 files changed, 63 insertions(+), 26 deletions(-) diff --git a/courier_protobuf/LICENSE b/courier_protobuf/LICENSE index ba75c69..34d884a 100644 --- a/courier_protobuf/LICENSE +++ b/courier_protobuf/LICENSE @@ -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. \ No newline at end of file diff --git a/courier_protobuf/README.md b/courier_protobuf/README.md index 02fe8ec..fcd4260 100644 --- a/courier_protobuf/README.md +++ b/courier_protobuf/README.md @@ -1,39 +1,56 @@ - +## 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 [ + ProtobufMessageAdapter(), + ... + ]) + ); +``` + +Decode bytes to Pet.pb GeneratedMessage: ```dart -const like = 'sample'; +courierClient + .courierMessageStream( + "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)); +``` \ No newline at end of file