sync message on recoonect on ui

This commit is contained in:
Peter Maquiran
2024-08-27 15:42:11 +01:00
parent a8395b941e
commit 7800b65cba
17 changed files with 293 additions and 33 deletions
+1
View File
@@ -9,5 +9,6 @@ export abstract class ISignalRService {
abstract join(): void;
abstract getData<T>(): Observable<{ method: string; data: T }>;
abstract getConnectionState(): Observable<boolean>;
abstract onReconnect(): Observable<boolean>;
abstract newConnection(): void;
}
@@ -3,8 +3,7 @@ import { BehaviorSubject, Observable, Subject, timer } from 'rxjs';
import { Platform } from '@ionic/angular';
import { SignalRConnection, SocketMessage } from './signalR';
import { Plugins } from '@capacitor/core';
import { z } from 'zod';
import { filter, map, switchMap } from 'rxjs/operators';
import { filter, map, skip, switchMap } from 'rxjs/operators';
import { Result } from 'neverthrow';
import { HubConnection } from '@microsoft/signalr';
import { MessageOutPutDataDTO } from 'src/app/module/chat/data/dto/message/messageOutputDTO';
@@ -127,9 +126,17 @@ export class SignalRService {
return this.connection.join()
}
// onReconnect() {
// const connection = this.getConnectionState()
// return connection.pipe(
// skip(1) // Skip the first value
// )
// }
getData<T>() {
return this.sendDataSubject.asObservable() as BehaviorSubject<{method: string, data: T}>
}
public getConnectionState(): Observable<boolean> {
return this.connectingSubject.asObservable();
}
-2
View File
@@ -58,8 +58,6 @@ export class SignalRConnection {
})
.catch(error => {
console.log('Error while starting connection: ' + error);
this.connectionStateSubject.next(false);
if(this.hasConnectOnce) {
setTimeout(()=> {
this.attempReconnect();