# Chat-SocketIO for listening to image messages

**URL:** <https://forum.social.plus/t/chat-socketio-for-listening-to-image-messages/1378>\
**Category:** Flutter\
**Created:** [July 5, 2024, 1:16am UTC](https://forum.social.plus/t/chat-socketio-for-listening-to-image-messages/1378 "2024-07-05T01:16:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cedBYW](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@cedBYW](https://forum.social.plus/u/cedBYW)\
**Post date:** [July 5, 2024, 1:16am UTC](https://forum.social.plus/t/chat-socketio-for-listening-to-image-messages/1378/1 "2024-07-05T01:16:21Z")

</div>

Hi,

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.

Thank you for your help!

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [July 5, 2024, 4:23am UTC](https://forum.social.plus/t/chat-socketio-for-listening-to-image-messages/1378/2 "2024-07-05T04:23:17Z")

</div>

Hello @cedBYW,

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](https://docs.amity.co/amity-sdk/chat/messaging/query-and-filter-messages).

---

<div class="post-metadata">

**Author:** ![cedBYW](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@cedBYW](https://forum.social.plus/u/cedBYW)\
**Post date:** [July 8, 2024, 7:43pm UTC](https://forum.social.plus/t/chat-socketio-for-listening-to-image-messages/1378/3 "2024-07-08T19:43:40Z")

</div>

Hi,

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?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [July 9, 2024, 8:15am UTC](https://forum.social.plus/t/chat-socketio-for-listening-to-image-messages/1378/4 "2024-07-09T08:15:06Z")

</div>

Hello @cedBYW , Thank you for your message.

I appreciate your feedback and understand the confusion. To clarify:

1. The document you referenced pertains to webhooks, not WebSockets.
2. 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.
3. The code you mentioned is outdated and will be removed soon. We do not recommend using it as a guideline for development.

---

<div class="post-metadata">

**Author:** ![cedBYW](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@cedBYW](https://forum.social.plus/u/cedBYW)\
**Post date:** [July 9, 2024, 6:24pm UTC](https://forum.social.plus/t/chat-socketio-for-listening-to-image-messages/1378/5 "2024-07-09T18:24:09Z")

</div>

Thank you for your message.

Could you please then provide a valid example in Flutter for my needs if the code in the example is outdated?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [July 10, 2024, 4:10am UTC](https://forum.social.plus/t/chat-socketio-for-listening-to-image-messages/1378/6 "2024-07-10T04:10:53Z")

</div>

Hello @cedBYW ,We recommend using the SDK as outlined in this document: [Query and Filter Messages](https://docs.amity.co/amity-sdk/chat/messaging/query-and-filter-messages).

---

<div class="post-metadata">

**Author:** ![cedBYW](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@cedBYW](https://forum.social.plus/u/cedBYW)\
**Post date:** [July 16, 2024, 1:30am UTC](https://forum.social.plus/t/chat-socketio-for-listening-to-image-messages/1378/8 "2024-07-16T01:30:55Z")

</div>

Hi @SocialPlus_Support

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](https://docs.amity.co/amity-sdk/chat/messaging/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!
