Notifications
Last updated
Last updated
User online: Push message via long poll connection
How does long poll find user's connection among so many long polls? There will be a user sign-in process
A TCP connection is set after three time hand shake.
Client sends a request based on the connection.
Server interprets the connection. If valid, it will save the mapping between uid and tcp connection socket descriptor.
This descriptor will be saved on local cache or distributed cache.
User offline: Push message via APNs
To make sure that users could still receive notifications when the app is running in the background or not openned, third party notification (Apple Push Notification Service / Google Cloud Messaging) will be used.
Offline message push
When many offline messages need to be pushed to the end-user, there is a need to resort msgs.
The entire process for sending offline msgs
The connection layer (network gateway) will subscribe to the redis topic for offline msgs.
User goes online.
The connection layer (network gateway) will notify business layer that the user is online.
The business layer will publish msgs to redis topic for offline msgs.
Redis will fan out the offline messages to the connection layer. (The rearrangement happens on this layer)
The conneciton layer will push the message to clients.
http://www.52im.net/forum.php?mod=viewthread&tid=1762&ctid=11
http://www.52im.net/forum.php?mod=collection&action=view&ctid=11&fromop=all
https://yalantis.com/blog/push-notifications-mechanism-outline-ios-and-android/