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.

+1


a source to share


8 answers


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.



+3


a source


I suggest using Wireshark or any other network traffic inspector to see exactly what is happening on Yahoo Messenger while it is running.



+2


a source


There must be a "push architecture".

Servers cannot tolerate persistent pulls for large numbers of users.

+1


a source


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.

0


a source


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.

0


a source


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.
0


a source


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.

0


a source


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

0


a source







All Articles