Viewing version 0.9.3. Open the latest package page.
centrifuge
0.9.3Dart client to communicate with Centrifuge and Centrifugo from Flutter and VM over WebSockets
Readme
Websocket client for Centrifugo server and Centrifuge library.
There is no v1 release of this library yet – API still evolves. At the moment patch version updates only contain backwards compatible changes, minor version updates can have backwards incompatible API changes.
Check out client SDK API specification to learn how this SDK behaves. It's recommended to read that before starting to work with this SDK as the spec covers common SDK behavior - describes client and subscription state transitions, main options and methods. Also check out examples folder.
The features implemented by this SDK can be found in SDK feature matrix.
Note that custom WebSocket connection Upgrade headers can only be set on platforms that support dart:io. So notably custom headers set in the configuration of Client are ignored on the web platform.
The latest
centrifuge-dartis compatible only with the latest Centrifugo server (v4) and Centrifuge >= 0.25.0. For Centrifugo v2, Centrifugo v3 and Centrifuge < 0.25.0 you should usecentrifuge-dartv0.8.0.
Examples
example\flutter_appsimple chat applicationexample\chat_appone more chat exampleexample\consolesimple console application
Usage in background
When a mobile application goes to the background there are OS-specific limitations for established persistent connections - which can be silently closed shortly. Thus in most cases you need to disconnect from a server when app moves to the background and connect again when app goes to the foreground.
Instructions for maintainers/contributors
How to update protobuf definitions
- Install
protoccompiler - Install
protoc_pluginhttps://pub.dev/packages/protoc_plugin (dart pub global activate protoc_plugin) - cd
lib/src/protoand runprotoc --dart_out=. -I . client.proto - cd to root and run
dartfmt -w lib/ test/(install dartfmt withdart pub global activate dart_style)
How to release
- Update changelog
- Bump version in
pubspec.yaml, push, create new tag dart pub publish
Author
German Saprykin, saprykin.h@gmail.com
Changelog
[0.9.3]
- Add support for web platform – #73
[0.9.2]
[0.9.1]
- Fix setting initial connection token
- Fix setting connection data
- Fix LateInitializationError if transport is not initialized yet
- Better string representation of
UnsubscribedEvent
[0.9.0]
Breaking changes
This release adopts a new iteration of Centrifugal protocol and a new iteration of API. Client now behaves according to the client SDK API specification. The work has been done according to Centrifugo v4 roadmap.
Check out Centrifugo v4 release post that covers the reasoning behind changes.
All the current core features of Centrifugal client protocol are now supported here.
New release only works with Centrifugo >= v4.0.0 and Centrifuge >= 0.25.0. See Centrifugo v4 migration guide for details about the changes in the ecosystem.
Note, that Centrifugo v4 supports clients working over the previous protocol iteration, so you can update Centrifugo to v4 without any changes on the client side (but you need to turn on use_client_protocol_v1_by_default option in the configuration of Centrifugo, see Centrifugo v4 migration guide for details).
[0.8.0]
Version 0.8.0 is the next iteration of centrifuge-dart development. It pushes client closer to other clients in the ecosystem. It also contains several backwards incompatible changes.
- Return Futures from
Client.connect,Client.disconnect,Subscription.subscribe,Subscription.unsubscribemethods - addresses #31. - On initial connect fire
DisconnectEventon connection error - this makes behavior ofcentrifuge-dartsimilar to all other our clients - addresses #56. - Add client error stream to consume
ErrorEvent- each transport failure will emit error to this stream - addresses #56. - Refactor subscription statuses - add
subscribinganderrorstatuses. This change is mostly internal should not affect working with Subscriptions. - Do not call
UnsubscribeEventif subscription is not successfully subscribed (i.e. insubscribedstate). This makes behavior ofcentrifuge-dartsimilar to all other our clients. - Update disconnect reasons due to failed connection and calling
Client.Disconnectmethod - make it more similar to all other connector libraries in ecosystem. - Add default transport timeout (10 sec) – on connect and subscribe timeouts client will auto reconnect, calls like publish, history, rpc can now throw
TimeoutException. Also - properly pass timeout to the transport (was not before!). Again – this makes client behave similarly to all other connectors. - Add
presenceandpresenceStatsmethods for Subscription and on client top level (for server-side subscriptions). - Support
streamPositioninSubscribeSuccessEvent. - Support
streamPositioninServerSubscribeEvent. - Support
datainServerSubscribeEvent. - Implement
sendmethod to send async messages to a server. - Fix deletion during iteration over map when working with server-side subscriptions.
- Better event String representations.
- Improvements and fixes in examples.
[0.7.1]
- Add support for
datainSubscribeSuccessEvent. This is a custom data which can be sent by a server towards client connection in subscribe result. Note that due to the bug in Centrifugo server this feature only works in Centrifugo >= v3.0.3.
[0.7.0]
Update to work with Centrifuge >= v0.18.0 and Centrifugo v3.
Breaking change in server behavior. Client History API behavior changed in Centrifuge >= v0.18.0 and Centrifugo >= v3.0.0. When using history call it won't return all publications in a stream by default. See Centrifuge v0.18.0 release notes or Centrifugo v3 migration guide for more information and workaround on server-side.
- Protocol definitions updated to the latest version
- History method now accepts optional
limit,sinceandreversearguments and returnsHistoryResult - RPC call now requires method name as first argument (you can pass empty string to mimic previous behavior)
- Publish now returns
PublishResult - When working with Centrifugo v3 or Centrifuge >= v0.18.0 it's now possible to avoid using
?format=protobufin connection URL. Client will negotiate Protobuf protocol with a server using WebSocket subprotocol mechanism (in request headers).
[0.6.0]
Null safety migration
- library dependencies updated to null safe versions
- library code updated to support null safety in places where required
See issue #47 and pull request #48 for details.
[0.5.1]
- Skip handling for events from server-side subscriptions resulted in null pointer dereference
[0.5.0]
- Update protobuf dependency to
^1.0.1, thanks @Holofox
[0.4.1]
- Implement
removeSubscriptionmethod, thanks @tiamo
[0.4.0]
- Breaking changes
connectedproperty removed
[0.3.0]
- Breaking changes Changed API to avoid returning futures where they do not make sense – in
connectandsubscribemethods. - Client now uses Websocket Ping/Pong frames to find broken connection
- Support for private channel subscription using
onPrivateSubconfiguration callback function - Fix several null pointer dereferences in edge cases, throw
ClientDisconnectedErrorwhen there is an attempt to send protocol request over non-connected client. - Fix examples where subscribe could happen before stream handlers set
[0.2.0]
- Breaking changes Replaced subscribe method with getSubscription in Client.
- Added reconnection.
- Added history method to Subscription. Thanks vanelizarov.
- Added rpc method.
[0.1.0]
- Added authorization with JWT
- Added subscription to private channel with JWT
[0.0.1]
- Initial release
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.ir
flutter pub add 'centrifuge:0.9.3'pubspec.yaml
name: centrifuge
version: 0.9.3
description: >
Dart client to communicate with Centrifuge and Centrifugo from Flutter and VM
over WebSockets
homepage: https://github.com/centrifugal/centrifuge-dart
environment:
sdk: '>=2.12.0 <3.0.0'
dependencies:
fixnum: ^1.0.0
meta: ^1.3.0
protobuf: ^2.0.0
web_socket_channel: ^2.3.0
dev_dependencies:
build_runner: ^2.0.3
mockito: ^5.0.7
test: ^1.17.4
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.0.1 | Cached · Upstream SHA-256 matched | Download | db3faacd…bd6395 |
| 0.1.0 | Cached · Upstream SHA-256 matched | Download | 09f7e4de…6b0b62 |
| 0.2.0 | Cached · Upstream SHA-256 matched | Download | 23bb4439…ea7ae6 |
| 0.3.0 | Cached · Upstream SHA-256 matched | Download | 3b377680…8aab61 |
| 0.4.0 | Cached · Upstream SHA-256 matched | Download | 08e6f397…213fbc |
| 0.4.1 | Cached · Upstream SHA-256 matched | Download | 6bb61dec…98094b |
| 0.5.0 | Cached · Upstream SHA-256 matched | Download | fd063805…d18ae1 |
| 0.5.1 | Cached · Upstream SHA-256 matched | Download | 60d5f869…941458 |
| 0.6.0 | Cached · Upstream SHA-256 matched | Download | d219ec9a…037c10 |
| 0.7.0 | Cached · Upstream SHA-256 matched | Download | 6548eff6…235e80 |
| 0.7.1 | Cached · Upstream SHA-256 matched | Download | 56407e60…13ad2c |
| 0.8.0 | Cached · Upstream SHA-256 matched | Download | 5ac2b57e…b7620a |
| 0.9.0 | Cached · Upstream SHA-256 matched | Download | 1f281a39…016252 |
| 0.9.1 | Cached · Upstream SHA-256 matched | Download | 0b9abe02…7ab142 |
| 0.9.2 | Cached · Upstream SHA-256 matched | Download | c261d991…360df3 |
| 0.9.3 | Cached · Upstream SHA-256 matched | Download | 4cd31b8b…bd7d34 |
| 0.9.4 | Cached · Upstream SHA-256 matched | Download | fda87da9…272ec3 |
| 0.10.0 | Cached · Upstream SHA-256 matched | Download | a278ecc0…d447b3 |
| 0.11.0 | Cached · Upstream SHA-256 matched | Download | 26bc8e36…65c5ec |
| 0.12.0 | Cached · Upstream SHA-256 matched | Download | 8a836da8…ea9aef |
| 0.13.0 | Cached · Upstream SHA-256 matched | Download | 8cea9670…6c71c8 |
| 0.14.0 | Cached · Upstream SHA-256 matched | Download | c35b75c7…4e4d47 |
| 0.14.1 | Cached · Upstream SHA-256 matched | Download | 15b9aabc…7e2516 |
| 0.15.0 | Cached · Upstream SHA-256 matched | Download | bc4e20bc…a8eb01 |
| 0.15.1 | Cached · Upstream SHA-256 matched | Download | bcd1e205…ccdf09 |
| 0.16.0 | Cached · Upstream SHA-256 matched | Download | b8b3d3c6…522a6d |
| 0.17.0 | Cached · Upstream SHA-256 matched | Download | 96050368…f97c73 |
| 0.18.0 | Cached · Upstream SHA-256 matched | Download | fa943928…f530ba |
| 0.19.0 | Cached · Upstream SHA-256 matched | Download | 672d21fa…77253d |
| 0.19.1 | Cached · Upstream SHA-256 matched | Download | 27808466…6446ea |
| 0.20.0 | Cached · Upstream SHA-256 matched | Download | fae4f687…b2bc6a |
| 0.20.1 | Cached · Upstream SHA-256 matched | Download | 5f172511…1e177d |
| 0.21.0 | Cached · Upstream SHA-256 matched | Download | 7449dc56…2b7969 |
Dependencies
fixnum "^1.0.0"
meta "^1.3.0"
protobuf "^2.0.0"
web_socket_channel "^2.3.0"