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