Forum Moderators: open

Message Too Old, No Replies

"user is typing" message display

         

distorto

11:39 pm on Nov 27, 2007 (gmt 0)

10+ Year Member



I have built a web based instant messaging application for a site and I'd like a message to say "user is typing" when the person you're chatting with is typing. Gtalk does this, but Meebo doesn't provide the functionality (I only mention Meebo because it's a prominent web-based chat app).
It would be easy enough to have each key press that's not the enter key ping the server and update the other user, but it seems like that's a bad idea - too much. I read somewhere that MSN does the "user is typing" message by detecting when the text box is not empty and then leaving the message until the message gets sent, but this seems to imply that we would need a timeout if the user hasn't hit a key after a certain period of time - and that sort of brings me back to the beginning.
does anyone know how I might go about doing this?

Chris_Mohr

7:57 am on Nov 28, 2007 (gmt 0)

10+ Year Member



I think the key would be sending two different messages to the server..."is typing" and "not typing"....here is some ugly pseudo code, I hope it makes sense:

On Key press - Send "is typing" message to server
- isTyping = true
- Note time of key press (tKeyPress = new Date();)

Loop forever{
- sleep one second
- timeNow = new Date()

if isTyping is true AND timeNow > tKeyPress + 10 seconds {
- send "not typing" message to server
- isTyping = false
}
}

Trace

2:41 pm on Nov 28, 2007 (gmt 0)

10+ Year Member



If I had to guess, I would think that you would send the status "is typing" when the textbox receives focus and then send "stopped typing" when the textbox loses focus.

Just seems like there would be a whole lot less back and forth that way.

distorto

3:56 pm on Nov 28, 2007 (gmt 0)

10+ Year Member



that's great. Focus on the textbox seems very reasonable. Thanks.