0

Possible Duplicate:
How to make a real time “User is typing” notice to all in chat

I'm developing PHP MySQL jQuery/Ajax chat, and trying to enchase it with some fancy features like User is typing... message

I found plenty of topics users describing how to make requests to inform server user is typing message, but that's not issue. I need a help in next step :) How to make "handover" of isTyping variable from client to client using server? I want to try to avoid storing it as it can overwhelm DB engine with unnecessary data. Is there some way to do so just using servers RAM? This data is not crucial so possibility of losing it is not big deal. Memcached is also an option, but preferred not.

Tnx in advance

Community
  • 1
  • 1
dzona
  • 3,323
  • 3
  • 31
  • 47

1 Answers1

4

PHP/MySQL is not the right stack to develop a chat in my opinion.

That's because such stack is stateless, and can't track user events: well it could actually, making use of sessions and database, but this implies continue polling from clients in order to retrieve changes in the state, and it implies:

  • are there new messages for me?
  • hey, are there new messages for me?
  • be kind, tell me if there are any messages for me.

The finest approach is to go with socket.io over node.js: long story short you have a persistent connection [using WebSockets, long polling and such tecniques] between clients and server, and it becomes a simple setup of event listeners on all the sides of the application.

You can find a live example here.

moonwave99
  • 21,957
  • 3
  • 43
  • 64