The discussion revolves around setting up MessageBus for real-time communication in a Dart-Flutter application interacting with Discourse. Sembauke is concerned about the performance impact of polling every 30 seconds and seeks a WebSocket-based solution, noting MessageBus is available but poorly documented. david suggests using Discourse’s WebHooks as an alternative, where Discourse notifies a backend, which then communicates with the Flutter app. bitmage clarifies that WebHooks are not directly usable by the Flutter frontend and proposes a Dart implementation of MessageBus, possibly by reverse-engineering the JavaScript client or using JS-to-Dart bindings. david reiterates that WebHooks would be handled via a backend, not directly by the app.
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:
So my question is if anyone has any idea how to solve this problem and has any experience using Message bus or Flutter Websockets.
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:
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.