Websocket integration is one of the biggest issues I had in my whole experience with Android. Why is it such a huge pain? There are several reasons behind that:
- Connection should remain stable no matter what – and we know how complex the Android lifecycle can be.
- Sending data can be a one-way operation without giving any result – did you succeed in sending it or did you fail? Only Server knows.
- Retrying connection or network requests can be tricky to implement – from pushing logic to interactors to having an internal logic inside a repository, be sure – nothing will work at 100%. Not even at 90% either.
- To get it right you need both frontend and backend collaboration. Nothing can be done if both sides do it separated from each other.