centrifugal / centrifuge-dart

Dart (Flutter) client SDK for bidirectional communication with Centrifugo and Centrifuge-based server over WebSocket
https://pub.dartlang.org/packages/centrifuge
MIT License
102 stars 29 forks source link

Support subscribe result data #54

Closed FZambia closed 2 years ago

FZambia commented 2 years ago

Adds data field to SubscribeSuccessEvent. This allows to put some custom data on server side to be available only to current connection. I.e. some initial subscription data. Specifically, this makes it possible to use data from Subscribe proxy: https://centrifugal.dev/docs/server/proxy#subscribe-proxy.

SimonVillage commented 2 years ago

https://github.com/centrifugal/centrifuge-dart/blob/aff43ea3dc52c1ceaf77f2c83a82eb4f24552cdc/lib/src/events.dart#L230-L232

Should this change to something like

  String toString() {
    return 'SubscribeSuccessEvent{isResubscribed: $isResubscribed, isRecovered: $isRecovered, data: ${utf8.decode(data, allowMalformed: true)}}';
  }
FZambia commented 2 years ago

Should this change to something like

I think no - this is just a string representation so no need to include all fields to it, specifically data can be non utf-8 (any binary supported here) and several kilobytes long for example.

FZambia commented 2 years ago

Actually just noticed that for ConnectEvent we already have data included in string representation. So let's be consistent – added data to string method for SubscribeSuccessEvent too.