2

I was chatting frequently in Facebook and as I love to code more and more so I tried to create a Chat Script! Here it is ::: http://wooflux.co.cc/ChatSystem.1.1/ChatSystem.1.1/

You try it out. But it is just a beta version so there are some bugs in it. And one of the biggest bug is that it requires a good internet speed to get real time updates. But when I push my net's speed to it's maximum and then chat with one of my friends in Facebook, it work in real time! I was wondering how did they do that? Can anyone explain me how they achieved this. Currently I'm sending Ajax requests in number intervals to get real time update. So please help me out by explaining or giving a link that how did Facebook achieved real time Chats without using much of the Internet speed?

j0k
  • 21,914
  • 28
  • 75
  • 84
Jack Billy
  • 6,881
  • 6
  • 25
  • 38

3 Answers3

8

To do real time communication you need a proper connection.

You can use WebSockets to give you a real Browser - Server TCP connection.

The alternative to WebSockets would be a flash bridge (which uses websockets in flash) or COMET techniques.

My personal recommendation is a WebSocket abstraction like socket.io.

Socket.io builds on node.js which Serverside Javascript. It excels at evented asynchronous real time communication.

If your going down the node route you might aswell pick up now to make your life easy. It has a screencast about making a chat server in 12 lines.

Raynos
  • 156,883
  • 55
  • 337
  • 385
0

I don't know how Facebook does it, but we use Node.js for pushing. Visit http://www.no-margin-for-errors.com/blog/2010/07/26/deliver-real-time-information-to-your-users-using-node-js/ for an example.

Mukesh Ram
  • 5,814
  • 4
  • 15
  • 34
Rufinus
  • 24,700
  • 6
  • 60
  • 78
0

Use COMET to push your messages to the client instead of polling your server all the time

See: Using comet with PHP?

Community
  • 1
  • 1
Jay Sidri
  • 5,877
  • 3
  • 36
  • 53