0

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?

1
  • "How do implement this most easily?" You can't - this is one of the trickiest things to do with HTTP. Feb 2, 2010 at 14:27

3 Answers 3

0

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.

1
  • Making a separate request on each keypress would be extremely inefficient.
    – SLaks
    Feb 2, 2010 at 14:32
0

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.

0

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

4
  • Have you ever digg into how Strophe.js implements Comet?
    – user198729
    Feb 2, 2010 at 16:44
  • No, i didn't. And i'm sure its a server technology - long-help request a-la Comet. So here we need to talk about "how jabber server (BOSH) implements it".
    – NilColor
    Feb 2, 2010 at 21:17
  • Actually,I don't think it's a pure server technology.
    – user198729
    Feb 3, 2010 at 10:43
  • Yes, its not. Client must understand that this request must be long-held. Personally i prefer xmpp way. But Comet is good too. You can choose - each of them can help you with all kind of chat notifications. But keep in mind thad jabber servers already support it (via presence/iq/etc stanzas) and you can chat with people who uses desctop clients like Adium/Miranda. With Comet you can't do this.
    – NilColor
    Feb 3, 2010 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.