How to emulate the instagram/facebook active status and message read functions

Viewed 81

I have been thinking about how the instagram/facebook messenger function of active status and message read for Wechat the Chinese app. So I was just curious how those functions work and how they are programmed. So I am just curious if there are any sources as to how those functionalities are implemented in real life.

1 Answers

This will require several round-trips between clients (Android/iOS apps, Web client) and server.

  • For message read status, the triggering point should come from client application. When User A e.g. open the chat apps window specific to a counterpart user (User B), then it needs to notify server. Subsequently server will notify User B that User A has open the chat window. The application on User B will need to change the display based on this new information, such as change the tick status etc.
    The implementation can be a bit more complicated than this as it may have to work based on the timestamp of each message.

    Notifying server in Erlang can be as simple as http(s) based API call. If two-ways persistent connection is needed, you can use (websocket) - the android and iOS client library for this is also available on the net.
  • active status can be triggered from server based on the last activity of a user. In this case, server will broadcast the last active timestamp to all 'friends/contacts', probably with other information such as user status and DP image.

    Above is the simplified flow, where more works will have to be done on the server side, such as maintaining the contact lists for all users, maintaining message delivery ordering, storing the timestamp of last activity of each user, etc.
Related