{"id":16401480,"url":"https://github.com/plugfox/spinify","last_synced_at":"2025-10-07T13:21:35.940Z","repository":{"id":181625929,"uuid":"667039229","full_name":"PlugFox/spinify","owner":"PlugFox","description":"Dart (Flutter) client SDK for bidirectional communication with Centrifugo and Centrifuge-based server over WebSocket","archived":false,"fork":false,"pushed_at":"2024-11-21T16:58:48.000Z","size":714,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-24T20:43:28.735Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PlugFox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"patreon":"plugfox","custom":["https://www.buymeacoffee.com/plugfox","https://boosty.to/plugfox"]}},"created_at":"2023-07-16T12:47:42.000Z","updated_at":"2024-11-21T16:58:52.000Z","dependencies_parsed_at":"2023-07-16T15:37:00.715Z","dependency_job_id":"6a6306d4-1b54-4356-8a19-9eb329d32ad3","html_url":"https://github.com/PlugFox/spinify","commit_stats":null,"previous_names":["plugfox/centrifuge-dart","plugfox/spinify"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugFox%2Fspinify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugFox%2Fspinify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugFox%2Fspinify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlugFox%2Fspinify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlugFox","download_url":"https://codeload.github.com/PlugFox/spinify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244277057,"owners_count":20427309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T05:43:13.090Z","updated_at":"2025-10-07T13:21:30.890Z","avatar_url":"https://github.com/PlugFox.png","language":"Dart","readme":"# Spinify\n\n[![Pub](https://img.shields.io/pub/v/spinify.svg)](https://pub.dev/packages/spinify)\n[![Actions Status](https://github.com/PlugFox/spinify/actions/workflows/checkout.yml/badge.svg)](https://github.com/PlugFox/spinify/actions)\n[![Coverage](https://codecov.io/gh/PlugFox/spinify/branch/master/graph/badge.svg)](https://codecov.io/gh/PlugFox/spinify)\n[![License: MIT](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT)\n[![Linter](https://img.shields.io/badge/style-linter-40c4ff.svg)](https://pub.dev/packages/linter)\n[![GitHub stars](https://img.shields.io/github/stars/plugfox/spinify?style=social)](https://github.com/plugfox/spinify/)\n\nSpinify is a Dart and Flutter library that provides an efficient client implementation for [Centrifugo](https://centrifugal.dev/), a scalable real-time messaging server.\nThis library allows you to connect your Dart or Flutter applications to [Centrifugo server](https://github.com/centrifugal/centrifugo) and [Centrifuge library](https://github.com/centrifugal/centrifuge), enabling real-time updates, presence information, history fetching, and more.\n\n## Features\n\n- **Connection Management**: Establish, monitor, and close connections to Centrifugo servers.\n- **Subscriptions**: Create, manage, and remove client-side and server-side subscriptions.\n- **Event Streaming**: Stream channel events for real-time updates.\n- **Data Publishing**: Publish messages to specific channels.\n- **Asynchronous Messaging**: Send custom asynchronous messages to the server.\n- **Presence Management**: Retrieve presence and presence statistics for channels.\n- **History Retrieval**: Fetch publication history for specific channels.\n- **Remote Procedure Calls (RPC)**: Perform server-side method invocations.\n- **Metrics**: Access metrics for client performance and statistics.\n- **Reconnecting**: Automatically reconnect to the server in case of a connection failure.\n- **Protobuf Transport**: Use Protobuf codec for data serialization.\n- **Custom Configuration**: Configure client settings, timeouts, and transport options.\n- **Error Handling**: Handle errors and exceptions gracefully.\n- **Logging**: Log events, errors, and messages for debugging purposes.\n- **Cross-Platform**: Run on Dart VM, Flutter, and Web platforms.\n- **Performance**: Achieve high throughput and low latency for real-time messaging.\n- **Headers Emulation**: Emulate HTTP headers for WebSocket connections at the Web platform.\n\n## Installation\n\nAdd the following dependency to your `pubspec.yaml` file and specify the version:\n\n```yaml\ndependencies:\n  spinify: ^X.Y.Z\n```\n\nThen fetch the package using:\n\n```bash\nflutter pub get\n```\n\n## Examples\n\nSimple usage of the library:\n\n```dart\nfinal client = Spinify();\nawait client.connect(url);\n// ...\nawait client.close();\n```\n\nAdd custom configuration:\n\n```dart\nfinal httpClient = io.HttpClient(\n  context: io.SecurityContext(\n    withTrustedRoots: true,\n  )..setTrustedCertificatesBytes([/* bytes array */]),\n);\n\nfinal client = Spinify(\n  config: SpinifyConfig(\n    client: (name: 'app', version: '1.0.0'),\n    timeout: const Duration(seconds: 15),\n    serverPingDelay: const Duration(seconds: 8),\n    connectionRetryInterval: (\n      min: const Duration(milliseconds: 250),\n      max: const Duration(seconds: 15),\n    ),\n    getToken: () async =\u003e '\u003ctoken\u003e',\n    getPayload: () async =\u003e utf8.encode('Hello, World!'),\n    codec: SpinifyProtobufCodec(),\n    transportBuilder: SpinifyTransportAdapter.vm(\n      compression: io.CompressionOptions.compressionDefault,\n      customClient: httpClient,\n      userAgent: 'Dart',\n    ),\n    logger: (level, event, message, context) =\u003e print('[$event] $message'),\n  ),\n);\n```\n\nSubscribe to a channel:\n\n```dart\nfinal sub = client.newSubscription('notifications:index');\nsub.stream.publication().map((p) =\u003e utf8.decode(p.data)).listen(print);\nawait sub.subscribe();\nawait sub.publish(utf8.encode('Hello, World!'));\nawait sub.unsubscribe();\n```\n\n## Benchmarks\n\nThis benchmark measures the performance of the [spinify](https://pub.dev/packages/spinify) and [centrifuge-dart](https://pub.dev/packages/centrifuge) libraries by sending and receiving a series of messages to a Centrifugo server and tracking key performance metrics such as throughput and latency.\n\nEnvironment:\n\n```\nWindows 11 Pro 64-bit\nCPU 13th Gen Intel Core i7-13700K\nChrome Version 131.0.6778.86 (Official Build) (64-bit)\nDocker version 27.1.1\nDocker image centrifugo/centrifugo:latest\nFlutter 3.24.5 • Dart 3.5.4\nPackage spinify v0.1.0\nPackage centrifuge-dart v0.14.1\n```\n\nThe benchmark sends 10,000 messages of a certain size one after the other and measure the time.\nEach message is sent sequentially: the client waits for the server's response before sending the next message.\n\n### Windows (Dart VM)\n\n|       | Spinify             | Centrifuge-Dart     |\n| ----- | ------------------- | ------------------- |\n| 1 KB  | 5396 msg/s (6MB/s)  | 5433 msg/s (6MB/s)  |\n| 14 KB | 3216 msg/s (46MB/s) | 3224 msg/s (46MB/s) |\n| 30 KB | 2371 msg/s (71MB/s) | 2352 msg/s (70MB/s) |\n| 60 KB | 1558 msg/s (92MB/s) | 1547 msg/s (91MB/s) |\n\n_\\* Messages larger than 64 KB are not supported._\n\n### Browser (WASM and JS)\n\n|       | Spinify WASM        | Spinify JS          | Centrifuge-Dart JS  |\n| ----- | ------------------- | ------------------- | ------------------- |\n| 1 KB  | 3676 msg/s (4MB/s)  | 3590 msg/s (6MB/s)  | 3720 msg/s (6MB/s)  |\n| 5 KB  | 2659 msg/s (13MB/s) | 3227 msg/s (18MB/s) | 3223 msg/s (18MB/s) |\n| 10 KB | 1926 msg/s (19MB/s) | 3031 msg/s (32MB/s) | 3029 msg/s (32MB/s) |\n| 14 KB | 1670 msg/s (22MB/s) | 2750 msg/s (39MB/s) | 2830 msg/s (40MB/s) |\n\n_\\* After message sizes exceed 15 KB, there is a noticeable performance drop._\n\n## Roadmap\n\n- ✅ Connect to a server\n- ✅ Setting client configuration\n- ✅ Automatic reconnect with backoff algorithm\n- ✅ Client state changes\n- ✅ Protobuf transport\n- ✅ Command-reply\n- ✅ Command timeouts\n- ✅ Async pushes\n- ✅ Ping-pong\n- ✅ Connection token refresh\n- ✅ Server-side subscriptions\n- ✅ Presence information\n- ✅ Presence stats\n- ✅ History information\n- ✅ Send custom RPC commands\n- ✅ Handle disconnect advice from the server\n- ✅ Channel subscription\n- ✅ Setting subscription options\n- ✅ Automatic resubscribe with backoff algorithm\n- ✅ Subscription state changes\n- ✅ Subscription command-reply\n- ✅ Subscription token refresh\n- ✅ Handle unsubscribe advice from the server\n- ✅ Manage subscription registry\n- ✅ Publish data into a channel\n- ✅ Set observer for hooking events \u0026 errors\n- ✅ Metrics and stats\n- ✅ Package errors\n- ✅ Meta information about the library\n- ✅ Web transport via extension type\n- ✅ Benchmarks\n- ✅ Performance comparison with other libraries\n- ✅ WASM compatibility\n- ✅ Headers emulation\n- ❌ 95% test coverage\n- ❌ JSON codec support for transport\n- ❌ DevTools extension\n- ❌ Run in separate isolate\n- ❌ Middleware support\n- ❌ Batching API\n- ❌ Bidirectional WebSocket emulation\n- ❌ Optimistic subscriptions\n- ❌ Delta compression\n\n## More resources\n\n- [Library documentation](https://pub.dev/documentation/spinify/latest/)\n- [RFC 6455: The WebSocket Protocol](https://tools.ietf.org/html/rfc6455)\n- [WebSocket API on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)\n- [Dart HTML WebSocket library](https://api.dart.dev/stable/dart-html/WebSocket-class.html)\n- [Dart IO WebSocket library](https://api.dart.dev/stable/dart-io/WebSocket-class.html)\n- [Centrifugo site](https://centrifugal.dev/)\n- [Client SDK API](https://centrifugal.dev/docs/transports/client_api)\n- [Client real-time SDKs](https://centrifugal.dev/docs/transports/client_sdk)\n- [Client protocol](https://centrifugal.dev/docs/transports/client_protocol)\n- [Protocol Buffers](https://protobuf.dev/)\n\n## Coverage\n\n[![](https://codecov.io/gh/PlugFox/spinify/branch/master/graphs/sunburst.svg)](https://codecov.io/gh/PlugFox/spinify/branch/master)\n\n## Changelog\n\nRefer to the [Changelog](https://github.com/PlugFox/spinify/blob/master/CHANGELOG.md) to get all release notes.\n\n## Maintainers\n\n- [Mike Matiunin aka Plague Fox](https://plugfox.dev)\n\n## Funding\n\nIf you want to support the development of our library, there are several ways you can do it:\n\n- [Buy me a coffee](https://www.buymeacoffee.com/plugfox)\n- [Support on Patreon](https://www.patreon.com/plugfox)\n- [Subscribe through Boosty](https://boosty.to/plugfox)\n\nWe appreciate any form of support, whether it's a financial donation or just a star on GitHub. It helps us to continue developing and improving our library. Thank you for your support!\n\n## License\n\n[The MIT License](https://opensource.org/licenses/MIT)\n","funding_links":["https://patreon.com/plugfox","https://www.buymeacoffee.com/plugfox","https://boosty.to/plugfox","https://www.patreon.com/plugfox"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplugfox%2Fspinify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplugfox%2Fspinify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplugfox%2Fspinify/lists"}