centrifuge 0.1.0 copy "centrifuge: ^0.1.0" to clipboard
centrifuge: ^0.1.0 copied to clipboard

outdated

Dart client to communicate with Centrifuge and Centrifugo from Flutter and VM over dart:io WebSocket

Build Status

Example #

Examples:

  • example\flutter_app simple chat application
  • example\console simple console application

Usage #

Create client:

import 'package:centrifuge/centrifuge.dart' as centrifuge;

final client = centrifuge.createClient(url);

Connect to server:

await client.connect();

Subscribe to channel:

final subscription = client.subscribe(channel);

subscription.publishStream.listen(onEvent);
subscription.joinStream.listen(onEvent);
subscription.leaveStream.listen(onEvent);

subscription.subscribeSuccessStream.listen(onEvent);
subscription.subscribeErrorStream.listen(onEvent);
subscription.unsubscribeStream.listen(onEvent);

Subscribe to private channel:

final privateSubscription = client.subscribe(channel, token: 'token');

Publish:

final output = jsonEncode({'input': message});
final data = utf8.encode(output);
await subscription.publish(data);

Checklist: #

  • ❌ connect to server using JSON protocol format
  • ✅ connect to server using Protobuf protocol format
  • ✅ connect with JWT
  • ❌ connect with custom header
  • ❌ support automatic reconnect in case of errors, network problems etc
  • ❌ connect and disconnect events
  • ❌ handle disconnect reason
  • ✅ subscribe on channel and handle asynchronous Publications
  • ✅ handle Join and Leave messages
  • ✅ handle unsubscribe notifications
  • ❌ handle subscribe error
  • ❌ support publish, presence, presence stats and history methods
  • ❌ send asynchronous messages to server
  • ✅ handle asynchronous messages from server
  • ❌ send RPC commands
  • ✅ subscribe to private channels with JWT
  • ❌ support connection JWT refresh
  • ❌ support private channel subscription JWT refresh
  • ❌ ping/pong to find broken connection
  • ❌ support message recovery mechanism

Author #

German Saprykin, saprykin.h@gmail.com

47
likes
0
points
32.8k
downloads

Publisher

unverified uploader

Weekly Downloads

Dart client to communicate with Centrifuge and Centrifugo from Flutter and VM over dart:io WebSocket

Repository
View/report issues

License

unknown (license)

Dependencies

meta, protobuf

More

Packages that depend on centrifuge