How do I notify users of another now?
I use yahoo messenger to chat with my friends. Every time my friend comes online (almost immediately), YM will notify me. How did Yahoo! (and other companies) to implement this? As far as I understand, there are several ways to solve this problem:
-
Pull: The client continually (perhaps 500ms in duration) asks the server that users (in the user list) have just logged on to, and then notifies the user.
-
Pushing: The server determines which users are connecting to the network and then sends a notification to the client.
The second approach is much more acceptable. User data can contain a list of his friend (who adds him to their lists) and the login event is raised, the server application will send a notification message to all users in that list.
OK, that's just my guess. How is this actually implemented? Can you tell me?
Thanks.
a source to share
the server dumps the data down. the server has a list of your friends, and more importantly, a list of the list you are on. when you login, it looks through this second list and sends a message to every connected client. it's pretty simple. see the Pidgin source code ( pidgin.im ) for more specific implementation details.
a source to share
Possibly long lasting HTTP requests. The IM client calls an HTTP method on the server, but the server doesn't respond until an update is available. At this point, it responds with an "update" and the IM client then calls another HTTP method to receive the update.
Real push is not possible because many (most?) People on the Internet are behind NAT routers.
a source to share
It uses similar Buddy Check technology , but only lets you know if the user wants to get to know you. But Verifying Friends really gives you the real truth.
a source to share
I agree with others that you can just explore the source code or networking packages yourself, but think about it from a different perspective: which approach makes more sense when you have hundreds of thousands of users and most users probably only have a few dozen. " buddies "?
- Ask hundreds of thousands of users to ping your servers every few seconds = a lot of load
- Send updates to clients when their friend statuses change, which probably happens on a much smaller scale - multiple updates every few minutes.
a source to share
When you log in, Yahoo sends (pushes) an "online event" to everyone on your list, which is also online. If the connection is HTTP, there is a ping / pong exchange between you and the Yahoo server to keep the connection ( wikipedia ) - which allows this push to happen through NAT and whatnot. In addition, the TCP / IP connection is maintained for the entire duration of your login. If ping / pong fails (after a few tries, you would guess), the Yahoo server sends (pushes) messages to all your friends on the network, notifying them of an "offline event".
So, to answer your question, this is a push.
a source to share
I know gtalk via gmail and facebook uses comet . it looks like a good technique, but its expensive. this is a nice tutotial in PHP
a source to share