2
0
mirror of https://github.com/tenrok/vue-native-websocket.git synced 2026-05-25 09:04:06 +03:00

fix reconnection ws instance

This commit is contained in:
Viktor Scheglov
2018-08-27 18:37:45 +03:00
parent a31cb5efb0
commit 2d4e4dfa29
3 changed files with 9 additions and 2 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+4
View File
@@ -8,6 +8,10 @@ export default {
let observer = null
opts.$setInstance = (wsInstance) => {
Vue.prototype.$socket = wsInstance
}
if (opts.connectManually) {
Vue.prototype.$connect = () => {
observer = new Observer(connection, opts)
+4 -1
View File
@@ -55,7 +55,10 @@ export default class {
if (this.store) { this.passToStore('SOCKET_' + eventType, event) }
if (this.reconnection && eventType === 'onopen') { this.reconnectionCount = 0 }
if (this.reconnection && eventType === 'onopen') {
this.opts.$setInstance(event.currentTarget)
this.reconnectionCount = 0
}
if (this.reconnection && eventType === 'onclose') { this.reconnect() }
}