Handling synchronization and errors
To make the chat messages functionality complete, we still have some issues we have to take into account: getting historical messages and receiver information and handling possible errors. We will go through them in this section.
Obtaining chat screen initialization data
Apart from the messages that we are going to be receiving or sending via the data source, we still need to get some additional information. This includes the following:
- Messages that have been sent and received before the WebSocket was connected (not all of them, though, because the conversation could have many messages, and it would take a long time to gather/load all of the information; instead we should prioritize fetching a certain number of the most recent messages)
- Receiver information, such as their name or avatar URL
There are several options to solve this – for example, we could have a different type of message with all this information when...