MCPcopy
hub / github.com/socketio/socket.io / updateTyping

Function updateTyping

examples/chat/public/main.js:149–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

147
148 // Updates the typing event
149 const updateTyping = () => {
150 if (connected) {
151 if (!typing) {
152 typing = true;
153 socket.emit('typing');
154 }
155 lastTypingTime = (new Date()).getTime();
156
157 setTimeout(() => {
158 const typingTimer = (new Date()).getTime();
159 const timeDiff = typingTimer - lastTypingTime;
160 if (timeDiff >= TYPING_TIMER_LENGTH && typing) {
161 socket.emit('stop typing');
162 typing = false;
163 }
164 }, TYPING_TIMER_LENGTH);
165 }
166 }
167
168 // Gets the 'X is typing' messages of a user
169 const getTypingMessages = (data) => {

Callers 1

main.jsFile · 0.70

Calls 1

emitMethod · 0.65

Tested by

no test coverage detected