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.