i'm having this chat app where i would like to add iMessage/Facebook feature where people know when each others are typing something, by changing their name's color e.g.
I have tried this :
$messageBox.keydown(function(){
if($(this).val().length!=0){ socket.emit('writing_message')};
});
socket.on('showing_writers',function(){
$users.html(''); // that was just to test if the event was well received, which is not the case...
});
I was hoping that this way, everytime a user presses a letters, it would trigger a very basic event on the server, which would respond to everyone like that :
socket.on('writing_message',function(){
io.sockets.emit('showing_writers', socket.nickname);
}
socket.nickname contains the user's nickname which I will use to find him back on all client's files, in order to change his name's color.
Does anyone know how to do it in a better way, and why what i'm doing is not working ?