Show in UX that there's a disconnect

This commit is contained in:
Saptak S 2020-06-07 15:56:05 +05:30
parent afc6a2f4ce
commit 08f891f4f6
No known key found for this signature in database
GPG Key ID: 2D9B32E54C68A3FB

View File

@ -23,6 +23,14 @@ $(function(){
addMessageToRoom(data, current_username, 'chat');
});
// Triggered when disconnected either by server stop or timeout
socket.on('disconnect', function(data) {
addMessageToRoom({'msg': 'The chat server is disconnected.'}, current_username, 'status');
})
socket.on('connect_error', function(error) {
console.log("error");
})
// Trigger new message on enter or click of send message button.
$('#new-message').on('keypress', function(e) {
var code = e.keyCode || e.which;