Buscar pacotes, repositórios e categorias de apps

Detalhes do pacotev0.21.0

centrifuge

Cliente Dart para se comunicar com o Centrifuge e Centrifugo do Flutter e VM por meio de WebSocket

AndroidiOSWebmacOSWindowsLinux
Downloads em 30 dias
76,5 mil
Curtidas
49
Pontos Pub
140

Instalar pacote

flutter pub add centrifuge

Visão geral do pacote

Orientação gerada a partir de informações públicas. Apenas para referência.

Centrifuge é um cliente Dart para comunicação em tempo real com servidores Centrifuge e Centrifugo por meio de WebSockets. Permite que aplicativos Flutter e VM se inscrevam em canais, recebam atualizações ao vivo e publiquem mensagens em tempo real. Projetado para interações de baixa latência, oferece gerenciamento de conexão, lógica de reconexão e transmissão de mensagens em múltiplas plataformas. Ideal para construir aplicativos de bate-papo, painéis ao vivo e ferramentas colaborativas que exigem sincronização instantânea de dados.

Casos de uso

  • Aplicações de bate-papo em tempo real
  • Atualizações ao vivo do painel
  • Ferramentas de edição colaborativa
  • Notificações push
  • sincronização de jogo multijogador

Principais recursos

  • Comunicação em tempo real baseada em WebSocket
  • Reconexão automática
  • Assinatura e publicação de canal
  • Suporte multiplataforma
  • Leve e eficiente
  • Autenticação de token seguro

Indicado para

  • Aplicativos móveis e web do Flutter
  • Serviços do Dart no lado do servidor
  • Streaming de dados em tempo real
  • Tratamento de eventos de alta frequência

Considerações

  • Requer um servidor Centrifuge ou Centrifugo em execução
  • Necessita de configuração adequada de autenticação
  • Pode ser necessário configurar permissões de rede no dispositivo móvel
  • Depende de conectividade estável por WebSocket

README original

Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.

Websocket client for Centrifugo server and Centrifuge library.

Since there is no v1 release yet, 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 are sent natively on platforms that support dart:io and in web context headers are sent using Centrifugo v6 Headers Emulation feature.

The latest centrifuge-dart is compatible with Centrifugo server v6, v5 and v4 and Centrifuge >= 0.25.0. For Centrifugo v2, Centrifugo v3 and Centrifuge < 0.25.0 you should use centrifuge-dart v0.8.0.

Examples

  • example\flutter_app simple chat application
  • example\chat_app one more chat example
  • example\console simple 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.

Alternative SDK

See also PlugFox/spinify for an alternative Dart (Flutter) real-time client SDK implementation.

Run tests locally

Start test Centrifugo server:

docker compose up

Then run tests:

dart run test --reporter expanded

Instructions for maintainers/contributors

How to update protobuf definitions
  1. Install protoc compiler
  2. Install protoc_plugin https://pub.dev/packages/protoc_plugin (dart pub global activate protoc_plugin)
  3. cd lib/src/proto and run protoc --dart_out=. -I . client.proto
  4. cd to root and run dartfmt -w lib/ test/ (install dartfmt with dart pub global activate dart_style)
How to release
  1. Update CHANGELOG.md, bump version in pubspec.yaml, push, create new tag
  2. [ONLY IF THERE ARE ISSUES WITH CI PUBLISH] dart pub publish

Author

German Saprykin, saprykin.h@gmail.com

Categorias

Dependências

Lista de dependências 4 itens

Repositório-fonte

Projetos que usam este pacote

Rankings