Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'User is typing a message' function...?

Just to point out I'm referring to chat systems written in PHP/jQuery where you see at the bottom 'User is typing a message...' I've tried so many methods to accomplish it but all fail, I built my own chat system written in PHP + MySQL/Ajax + jQuery.

I'm not asking for someone to write the function for me but just to give me a little example so I can get an idea of what to do.

I would greatly appreciate it, thanks in advance :)

like image 372
bennyyboi Avatar asked Dec 13 '10 11:12

bennyyboi


3 Answers

Use a timer to send an AJAX request onkeyup that tells the database the user is typing, on the other side when your pulling down chat messages you can then notify the other person that they are typing.

Take a look at doTimeOut which has a great example of debouncing in javascript...

http://benalman.com/code/projects/jquery-dotimeout/examples/debouncing/

like image 67
fire Avatar answered Oct 09 '22 10:10

fire


You could to try check if your message textbox is filled with something every n seconds. If so, fire an server request to update that status between both users.

like image 23
Rubens Farias Avatar answered Oct 09 '22 10:10

Rubens Farias


Using JavaScript check every (lets say) 2 seconds if any key is pressed at chat window. If yes, then send an Ajax request to tell your application that user is typing something.

like image 31
Garbage Avatar answered Oct 09 '22 10:10

Garbage