mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-04 10:26:02 -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 () {
|
data () {
|
||||||
return {
|
return {
|
||||||
token_timer_id: 0
|
token_timer_id: 0,
|
||||||
|
reconnect_attempts: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -88,11 +89,12 @@ export default {
|
|||||||
var socket = new ReconnectingWebSocket(
|
var socket = new ReconnectingWebSocket(
|
||||||
'ws://' + window.location.hostname + ':' + vm.$store.state.config.websocket_port,
|
'ws://' + window.location.hostname + ':' + vm.$store.state.config.websocket_port,
|
||||||
'notify',
|
'notify',
|
||||||
{ reconnectInterval: 5000 }
|
{ reconnectInterval: 3000 }
|
||||||
)
|
)
|
||||||
|
|
||||||
socket.onopen = function () {
|
socket.onopen = function () {
|
||||||
vm.$store.dispatch('add_notification', { text: 'Connection to server established', type: 'primary', topic: 'connection', timeout: 2000 })
|
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'] }))
|
socket.send(JSON.stringify({ notify: ['update', 'player', 'options', 'outputs', 'volume', 'spotify'] }))
|
||||||
|
|
||||||
vm.update_outputs()
|
vm.update_outputs()
|
||||||
@ -105,7 +107,8 @@ export default {
|
|||||||
// vm.$store.dispatch('add_notification', { text: 'Connection closed', type: 'danger', timeout: 2000 })
|
// vm.$store.dispatch('add_notification', { text: 'Connection closed', type: 'danger', timeout: 2000 })
|
||||||
}
|
}
|
||||||
socket.onerror = function () {
|
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) {
|
socket.onmessage = function (response) {
|
||||||
var data = JSON.parse(response.data)
|
var data = JSON.parse(response.data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user