mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-04 02:16:01 -05:00
[web-src] Reduce reconnect interval for web socket connection to 3s and
show number of reconnection attempts in notification message
This commit is contained in:
parent
388c8868d5
commit
6578f60f01
@ -25,7 +25,8 @@ export default {
|
||||
|
||||
data () {
|
||||
return {
|
||||
token_timer_id: 0
|
||||
token_timer_id: 0,
|
||||
reconnect_attempts: 0
|
||||
}
|
||||
},
|
||||
|
||||
@ -88,11 +89,12 @@ export default {
|
||||
var socket = new ReconnectingWebSocket(
|
||||
'ws://' + window.location.hostname + ':' + vm.$store.state.config.websocket_port,
|
||||
'notify',
|
||||
{ reconnectInterval: 5000 }
|
||||
{ reconnectInterval: 3000 }
|
||||
)
|
||||
|
||||
socket.onopen = function () {
|
||||
vm.$store.dispatch('add_notification', { text: 'Connection to server established', type: 'primary', topic: 'connection', timeout: 2000 })
|
||||
vm.reconnect_attempts = 0
|
||||
socket.send(JSON.stringify({ notify: ['update', 'player', 'options', 'outputs', 'volume', 'spotify'] }))
|
||||
|
||||
vm.update_outputs()
|
||||
@ -105,7 +107,8 @@ export default {
|
||||
// vm.$store.dispatch('add_notification', { text: 'Connection closed', type: 'danger', timeout: 2000 })
|
||||
}
|
||||
socket.onerror = function () {
|
||||
vm.$store.dispatch('add_notification', { text: 'Connection lost. Reconnecting ...', type: 'danger', topic: 'connection' })
|
||||
vm.reconnect_attempts++
|
||||
vm.$store.dispatch('add_notification', { text: 'Connection lost. Reconnecting ... (' + vm.reconnect_attempts + ')', type: 'danger', topic: 'connection' })
|
||||
}
|
||||
socket.onmessage = function (response) {
|
||||
var data = JSON.parse(response.data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user