I’m trying to get Image messages in realtime by listening to websocket events.
I tried using socket.on('message.didCreate' but it doesn’t contain the image information '(fileId, fileUrl). I tried to use the webhook version 5 v5.message.didCreate with my socket io connection but it doesn’t get any message.
Could you help? If there’s another method to listen in realtime to newly created messages with image/file information, I’m open to suggestions.
We do not provide support for WebSocket directly, so we recommend that you use the SDK to implement this feature. Please follow this documentation: Query and Filter Messages.
Thank you for your message. You do provide support for Websockets, it’s in your API documentation (https://api-docs.amity.co/#/Webhook%20event/get_webhook_v5_message_didCreate) and also in your FLutter SDK (https://github.com/AmityCo/Amity-Social-UIKit-Flutter-Opensource/blob/main/lib/repository/chat_repo_imp.dart).
Querying and filtering is not in realtime and reactive. There are no other example in your documentation and your Flutter examples to observe in realtime when a message is created and get the associated file information.
Could you please check with your Flutter development team?
I appreciate your feedback and understand the confusion. To clarify:
The document you referenced pertains to webhooks, not WebSockets.
We have recently updated our real-time connection protocol from WebSocket to MQTT protocol. As a result, we no longer provide technical support for WebSocket.
The code you mentioned is outdated and will be removed soon. We do not recommend using it as a guideline for development.
Thank you for your message. I finally managed to get a live collection of messages with image/file information but your SDK Flutter documentation is wrong.
Your Flutter instructions Query and Filter Messages using getPagingData does not send back a LiveCollection (it does not refresh on new message). The correct function call is getLiveCollection and then use the StreamController given to listen to page requests and new messages. None of this procedure is given in your documentation.
Besides, I don’t know if your flutter development team is aware that the mentioned StreamController is inefficient :
when the function getFirstPageRequest is called, the Stream listener is triggered for each message contained in the first page (so 10 times if there are 10 messages) with an incremental list of messages (first time with 1 message, second time with 2 messages … 10th time with 10 messages)
when the current user creates a new message, the Stream listener is triggered several times
I hope that helps. Thank you for your help and have a good one!