fix reconnect after WebSocket Timeout. fix typo, don't send messages thru data channel is connection is not opened

This commit is contained in:
Pawel Urbanek 2023-03-28 12:53:12 +02:00
parent 887413d536
commit f58259ec94
4 changed files with 15 additions and 10 deletions

View File

@ -158,22 +158,22 @@
mounted() { mounted() {
// auto-password fill // auto-password fill
let password = this.$accessor.password this.password = this.$accessor.password
if (this.autoPassword !== null) { if (this.autoPassword !== null) {
this.removeUrlParam('pwd') this.removeUrlParam('pwd')
password = this.autoPassword this.password = this.autoPassword
} }
// auto-user fill // auto-user fill
let displayname = this.$accessor.displayname this.displayname = this.$accessor.displayname
const usr = new URL(location.href).searchParams.get('usr') const usr = new URL(location.href).searchParams.get('usr')
if (usr) { if (usr) {
this.removeUrlParam('usr') this.removeUrlParam('usr')
displayname = this.$accessor.displayname || usr this.displayname = this.$accessor.displayname || usr
} }
if (displayname !== '' && password !== '') { if (this.displayname !== '' && this.password !== '') {
this.$accessor.login({ displayname, password }) this.$accessor.login({ displayname: this.displayname, password: this.password })
this.autoPassword = null this.autoPassword = null
} }
} }
@ -208,7 +208,6 @@
if (this.autoPassword !== null) { if (this.autoPassword !== null) {
password = this.autoPassword password = this.autoPassword
} }
if (this.displayname == '') { if (this.displayname == '') {
this.$swal({ this.$swal({
title: this.$t('connect.error') as string, title: this.$t('connect.error') as string,

View File

@ -173,7 +173,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
} }
// @ts-ignore // @ts-ignore
if (typeof buffer !== 'undefined') { if (typeof buffer !== 'undefined' && this._channel?.readyState == 'open') {
this._channel!.send(buffer) this._channel!.send(buffer)
} }
} }

View File

@ -85,7 +85,7 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
} }
protected [EVENT.CONNECTING]() { protected [EVENT.CONNECTING]() {
this.$accessor.setConnnecting() this.$accessor.setConnecting()
} }
protected [EVENT.CONNECTED]() { protected [EVENT.CONNECTED]() {
@ -117,6 +117,11 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
duration: 5000, duration: 5000,
speed: 1000, speed: 1000,
}) })
if (reason?.message == 'connection timeout') {
if (this.$accessor.displayname && this.$accessor.password) {
this.login(this.$accessor.password, this.$accessor.displayname)
}
}
} }
protected [EVENT.TRACK](event: RTCTrackEvent) { protected [EVENT.TRACK](event: RTCTrackEvent) {
@ -160,6 +165,7 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
text: message, text: message,
icon: 'error', icon: 'error',
confirmButtonText: this.$vue.$t('connection.button_confirm') as string, confirmButtonText: this.$vue.$t('connection.button_confirm') as string,
timer: 15000,
}) })
} }

View File

@ -41,7 +41,7 @@ export const mutations = mutationTree(state, {
Vue.set(state.locked, resource, false) Vue.set(state.locked, resource, false)
}, },
setConnnecting(state) { setConnecting(state) {
state.connected = false state.connected = false
state.connecting = true state.connecting = true
}, },