1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-09-21 03:19:36 +00:00

Fixed reconnecting to myMPD

This commit is contained in:
jcorporation 2018-05-27 14:10:34 +01:00
parent 577bc7843e
commit 7b3b7bd7d1
2 changed files with 23 additions and 5 deletions

View File

@ -249,6 +249,19 @@
</nav> </nav>
</footer> </footer>
<div class="modal" id="modalConnectionError" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><span class="material-icons">error</span> Connection Error</h5>
</div>
<div class="modal-body">
<p>Connection to myMPD failed. Trying to reconnect.</p>
</div>
</div>
</div>
</div>
<!-- Modal --> <!-- Modal -->
<div class="modal fade" id="settings" tabindex="-1" role="dialog" aria-labelledby="settingsLabel" aria-hidden="true"> <div class="modal fade" id="settings" tabindex="-1" role="dialog" aria-labelledby="settingsLabel" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog">

View File

@ -158,7 +158,7 @@ $(document).ready(function(){
$('#mainMenu').on('shown.bs.dropdown', function () { $('#mainMenu').on('shown.bs.dropdown', function () {
$('#search > input').val(''); $('#search > input').val('');
$('#search > input').focus(); $('#search > input').focus();
}) });
if(!notificationsSupported()) if(!notificationsSupported())
$('#btnnotifyWeb').addClass("disabled"); $('#btnnotifyWeb').addClass("disabled");
@ -183,7 +183,7 @@ function webSocketConnect() {
socket.onopen = function() { socket.onopen = function() {
console.log("connected"); console.log("connected");
showNotification('Connected to myMPD','','','success'); showNotification('Connected to myMPD','','','success');
$('#modalConnectionError').modal('hide');
app.run(); app.run();
/* emit initial request for output names */ /* emit initial request for output names */
socket.send('MPD_API_GET_OUTPUTS'); socket.send('MPD_API_GET_OUTPUTS');
@ -548,6 +548,7 @@ function webSocketConnect() {
break; break;
case 'disconnected': case 'disconnected':
showNotification('myMPD lost connection to MPD','','','danger'); showNotification('myMPD lost connection to MPD','','','danger');
break; break;
case 'update_queue': case 'update_queue':
if(current_app === 'queue') { if(current_app === 'queue') {
@ -568,8 +569,12 @@ function webSocketConnect() {
} }
socket.onclose = function(){ socket.onclose = function(){
console.log("disconnected"); console.log('disconnected');
showNotification('Connection to myMPD lost, retrying in 3 seconds','','','danger'); $('#modalConnectionError').modal('show');
setTimeout(function() {
console.log('reconnect');
webSocketConnect();
},3000);
} }
} catch(exception) { } catch(exception) {