I've seens this in various places,
during chat,I can see whether the other party is typing or not .
How do implement this most easily?
I've seens this in various places,
during chat,I can see whether the other party is typing or not .
How do implement this most easily?
You'll need to use AJAX.
When user A first presses a key, you can tell the server that he started typing.
5 seconds after the last keypress (call clearTimeout
and setTimeout
in onkeyup
), tell the server that he stopped.
Then, on user B's side, use polling or comet to ask the server what it received from user A.
The chat client code sends something back to the server when it sees a keyboard event. The server then either pushes information to other clients, or else the other clients poll the server every once in a while.
This is can be solved using XMPP/BOSH way. Check for Strophe.js -- very good xmpp library.
Or you can do this with AJAX and server polling... I'd recommend XMPP...