MessageBus - How to setup Messagebus using Dart-Flutter

Hey Everyone,

I am making a mobile application that uses the Discourse to GET and POST data. At the moment, I am making a request every 30 seconds to see if there are new posts on a topic. This seems like it could potentially harm our forum by accidentally d-dosing ourselfs.

I have been looking for a good solution using WebSockets in Flutter, but no luck yet. For Discourse, I came across MessageBus, which has confounding documentation.

Yet we do have MessageBus setup on our forum as seen in this polling request:
image

So my question is if anyone has any idea how to solve this problem and has any experience using Message bus or Flutter Websockets.

1 Like

MessageBus is an option - you can find client libraries for Ruby and JS here: GitHub - discourse/message_bus: A reliable and robust messaging bus for Ruby and Rack

But a simpler solution is probably to use Discourse’s WebHooks feature. That way, Discourse can make a web request to your endpoint whenever there is a new topic/post. You can find more information here:

5 Likes

I don’t see how webhooks would be related or useful at all to a Flutter frontend.

It seems like what OP is looking for is a Dart implementation of the MessageBus client… which would probably have to be reverse engineered from this Javascript code. Another alternative might be to run the Javascript code within Dart, and then wrap it in bindings to translate from Javascript to Dart. A direct port to Dart should be the more performant of these two.

Someone please correct me if I’m wrong. This isn’t something I’ve dug into, but I think the idea of a Flutter frontend is intriguing.

3 Likes

The idea would be Webhooks → your backend → your app. So, the app wouldn’t be receiving the webhooks directly.

4 Likes