mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
send offline message
This commit is contained in:
@@ -27,6 +27,7 @@ export class SignalRConnection {
|
||||
private sendDataSubject: BehaviorSubject<{method: string, data: any}> = new BehaviorSubject<{method: string, data: any}>(null);
|
||||
private pendingRequests: Map<string, { resolve: Function; reject: Function }> = new Map();
|
||||
url: string
|
||||
private hasConnectOnce = false
|
||||
|
||||
constructor({url}) {
|
||||
this.url = url
|
||||
@@ -44,6 +45,7 @@ export class SignalRConnection {
|
||||
hubConnection
|
||||
.start()
|
||||
.then(() => {
|
||||
this.hasConnectOnce = true
|
||||
console.log('Connection started');
|
||||
this.connectionStateSubject.next(true);
|
||||
this.hubConnection = hubConnection
|
||||
@@ -54,7 +56,13 @@ export class SignalRConnection {
|
||||
.catch(error => {
|
||||
console.log('Error while starting connection: ' + error);
|
||||
this.connectionStateSubject.next(false);
|
||||
reject(err(false))
|
||||
|
||||
if(this.hasConnectOnce) {
|
||||
setTimeout(()=> {
|
||||
this.attempReconnect();
|
||||
}, 2000)
|
||||
}
|
||||
resolve(err(false))
|
||||
});
|
||||
|
||||
hubConnection.onclose(() => {
|
||||
@@ -64,7 +72,7 @@ export class SignalRConnection {
|
||||
|
||||
this.pendingRequests.forEach((_, requestId) => {
|
||||
const { reject } = this.pendingRequests.get(requestId);
|
||||
reject(err('Connection closed================!s'));
|
||||
reject(err(false));
|
||||
this.pendingRequests.delete(requestId);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user