add synchro callbacks

This commit is contained in:
Peter Maquiran
2021-08-31 09:16:59 +01:00
parent f9e031254f
commit ca4f9e47de
2 changed files with 28 additions and 11 deletions
+17 -11
View File
@@ -81,11 +81,14 @@ class SynchroService {
this.BackgroundService.online()
this.callBacks.forEach((e)=>{
if(e.type == 'Online') {
e.funx()
}
})
if(!this.conected) {
this.callBacks.forEach((e)=>{
if(e.type == 'Online') {
e.funx()
}
})
}
console.log('open ======================= welcome to socket server')
this._connected = true
@@ -169,13 +172,16 @@ class SynchroService {
console.log('[close] Connection died');
console.log('Reconnect')
this.BackgroundService.offline();
this.callBacks.forEach((e)=>{
if(e.type == 'Offline') {
e.funx()
}
})
if(this._connected) {
this.BackgroundService.offline();
this.callBacks.forEach((e)=>{
if(e.type == 'Offline') {
e.funx()
}
})
}
// status
this._connected = false