Skip to content
Snippets Groups Projects
Commit 0ef7d89b authored by Simon Döring's avatar Simon Döring
Browse files

Show message on sender side when socket disconnects

parent da14a2e0
No related branches found
No related tags found
No related merge requests found
...@@ -54,6 +54,12 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -54,6 +54,12 @@ document.addEventListener('DOMContentLoaded', function() {
registerSocketHandlers(); registerSocketHandlers();
function handleUnexpectedSocketDisconnect() {
console.log('Socket disconnected');
setStatusMessage('Socket disconnected. This either means that you are having connectivity ' +
'issues or that the server disconnected you on purpose.', STATUS_CODE.error);
}
function registerSocketHandlers() { function registerSocketHandlers() {
socket.on('connect', function() { socket.on('connect', function() {
clearTimeout(cameraServerTimeout); clearTimeout(cameraServerTimeout);
...@@ -67,6 +73,7 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -67,6 +73,7 @@ document.addEventListener('DOMContentLoaded', function() {
); );
} }
}); });
socket.on('disconnect', handleUnexpectedSocketDisconnect);
}; };
function handleSenderInitResponse(data) { function handleSenderInitResponse(data) {
...@@ -288,7 +295,10 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -288,7 +295,10 @@ document.addEventListener('DOMContentLoaded', function() {
if (videoroomHandle) { if (videoroomHandle) {
videoroomHandle.detach(); videoroomHandle.detach();
} }
if (socket) { if (socket && socket.connected) {
// Remove handler because this disconnect call is expected
// in the case of an error
socket.off('disconnect', handleUnexpectedSocketDisconnect);
socket.disconnect(); socket.disconnect();
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment