show reconnecting notify. #48

This commit is contained in:
Miroslav Šedivý 2021-07-17 19:18:21 +02:00
parent 2cff2a340f
commit b9b80ed79a
9 changed files with 30 additions and 1 deletions

View File

@ -69,6 +69,7 @@ export const setting = {
export const connection = { export const connection = {
logged_out: 'You have been logged out.', logged_out: 'You have been logged out.',
reconnecting: 'Reconnecting...',
connected: 'Connected', connected: 'Connected',
disconnected: 'Disconnected', disconnected: 'Disconnected',
button_confirm: 'OK', button_confirm: 'OK',

View File

@ -69,6 +69,8 @@ export const setting = {
export const connection = { export const connection = {
logged_out: 'Has salido!', logged_out: 'Has salido!',
// TODO
//reconnecting: 'Reconnecting',
connected: 'Connectado correctamente', connected: 'Connectado correctamente',
disconnected: 'Has sido desconectado', disconnected: 'Has sido desconectado',
button_confirm: 'De acuerdo', button_confirm: 'De acuerdo',

View File

@ -69,6 +69,8 @@ export const setting = {
export const connection = { export const connection = {
logged_out: 'Vous avez été déconnecté.', logged_out: 'Vous avez été déconnecté.',
// TODO
//reconnecting: 'Reconnecting',
connected: 'Connecté', connected: 'Connecté',
disconnected: 'Déconnecté', disconnected: 'Déconnecté',
button_confirm: 'OK', button_confirm: 'OK',

View File

@ -69,6 +69,8 @@ export const setting = {
export const connection = { export const connection = {
logged_out: 'Du har blitt utlogget.', logged_out: 'Du har blitt utlogget.',
// TODO
//reconnecting: 'Reconnecting',
connected: 'Tilkoblet', connected: 'Tilkoblet',
disconnected: 'Frakoblet', disconnected: 'Frakoblet',
button_confirm: 'OK', button_confirm: 'OK',

View File

@ -69,6 +69,7 @@ export const setting = {
export const connection = { export const connection = {
logged_out: 'Boli ste odhlásený/á', logged_out: 'Boli ste odhlásený/á',
reconnecting: 'Obnova spojenia...',
connected: 'Úspešne pripojený/á', connected: 'Úspešne pripojený/á',
disconnected: 'Boli ste odpojený/á', disconnected: 'Boli ste odpojený/á',
button_confirm: 'Ok', button_confirm: 'Ok',

View File

@ -69,6 +69,8 @@ export const setting = {
export const connection = { export const connection = {
logged_out: 'Du har blivit utloggad!', logged_out: 'Du har blivit utloggad!',
// TODO
//reconnecting: 'Reconnecting',
connected: 'Du har loggats in', connected: 'Du har loggats in',
disconnected: 'Du har blivit frånkopplad', disconnected: 'Du har blivit frånkopplad',
button_confirm: 'Ok', button_confirm: 'Ok',

View File

@ -230,6 +230,9 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
case 'connected': case 'connected':
this.onConnected() this.onConnected()
break break
case 'disconnected':
this[EVENT.RECONNECTING]()
break
// https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling#ice_connection_state // https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Signaling_and_video_calling#ice_connection_state
// We don't watch the disconnected signaling state here as it can indicate temporary issues and may // We don't watch the disconnected signaling state here as it can indicate temporary issues and may
// go back to a connected state after some time. Watching it would close the video call on any temporary // go back to a connected state after some time. Watching it would close the video call on any temporary
@ -358,6 +361,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
this.emit('warn', `unhandled websocket event '${event}':`, payload) this.emit('warn', `unhandled websocket event '${event}':`, payload)
} }
protected abstract [EVENT.RECONNECTING](): void
protected abstract [EVENT.CONNECTING](): void protected abstract [EVENT.CONNECTING](): void
protected abstract [EVENT.CONNECTED](): void protected abstract [EVENT.CONNECTED](): void
protected abstract [EVENT.DISCONNECTED](reason?: Error): void protected abstract [EVENT.DISCONNECTED](reason?: Error): void

View File

@ -1,5 +1,6 @@
export const EVENT = { export const EVENT = {
// Internal Events // Internal Events
RECONNECTING: 'RECONNECTING',
CONNECTING: 'CONNECTING', CONNECTING: 'CONNECTING',
CONNECTED: 'CONNECTED', CONNECTED: 'CONNECTED',
DISCONNECTED: 'DISCONNECTED', DISCONNECTED: 'DISCONNECTED',

View File

@ -70,6 +70,16 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
///////////////////////////// /////////////////////////////
// Internal Events // Internal Events
///////////////////////////// /////////////////////////////
protected [EVENT.RECONNECTING]() {
this.$vue.$notify({
group: 'neko',
type: 'warning',
title: this.$vue.$t('connection.reconnecting') as string,
duration: 5000,
speed: 1000,
})
}
protected [EVENT.CONNECTING]() { protected [EVENT.CONNECTING]() {
this.$accessor.setConnnecting() this.$accessor.setConnnecting()
} }
@ -77,7 +87,11 @@ export class NekoClient extends BaseClient implements EventEmitter<NekoEvents> {
protected [EVENT.CONNECTED]() { protected [EVENT.CONNECTED]() {
this.$accessor.user.setMember(this.id) this.$accessor.user.setMember(this.id)
this.$accessor.setConnected(true) this.$accessor.setConnected(true)
this.$accessor.setConnected(true)
this.$vue.$notify({
group: 'neko',
clean: true,
})
this.$vue.$notify({ this.$vue.$notify({
group: 'neko', group: 'neko',