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
113 stars 34 forks source link

Is it possible to make use of proxy methods? #55

Closed SimonVillage closed 3 years ago

SimonVillage commented 3 years ago

Hi,

I am trying to implement proxy_subscribe_endpoint. The endpoint gets called on my backend on subscribe, I return a message like this:

{
  "result": {
    "data": {
      "hello": "world"
    }
  }
}

However, on the subscribeSuccessStream event I only receive SubscribeSuccessEvent{isResubscribed: false, isRecovered: false}

Is this functionality implemented already? I am trying to respond to the subscribing user with some initial user information.

FZambia commented 3 years ago

Could you please check out https://github.com/centrifugal/centrifuge-dart/pull/54 ?

SimonVillage commented 3 years ago

I applied the changes locally but it doesn't seem like that it works. It returns this right now:

SubscribeSuccessEvent{isResubscribed: false, isRecovered: false, data: [] }

I also changed to this

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

A response like this should be fine right?

{
      result: {
        data: { test: 1 },
      },
    }
FZambia commented 3 years ago

Sorry, the bug in a server – fixed by https://github.com/centrifugal/centrifugo/commit/fc07520fabe25026a98e85f00b69a4a4ab6ac7ae – will be available in next Centrifugo release.

FZambia commented 3 years ago

Released both Centrifugo v3.0.3 and centrifuge-dart v0.7.1 – returning data from subscribe proxy must be proxied towards data field of SubscribeSuccessEvent.