Socket.io how to check if user is typing and broadcast it to other users

后端 未结 4 456

I am trying to setup socket.io chat server. I have gotten it up to send and receive message from server and client. I was interested in showing users if some one is typing. I kn

4条回答
  •  梦毁少年i
    2021-02-02 03:43

       function typingtimeoutFunction (){                 
    
          socket.emit('typingMessage', 'stopped typing');    
        },
    
        onKeyDownNotEnter: function (){
             clearTimeout(this.typingtimeout);
             socket.emit('typingMessage', 'istyping');
            this.typingtimeout = setTimeout(function() {ajaxChat.typingtimeoutFunction();}, 5000);      
        },
    

提交回复
热议问题