mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
fix change
This commit is contained in:
@@ -3,7 +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 { filter, map, skip, switchMap } from 'rxjs/operators';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { Result } from 'neverthrow';
|
||||
import { HubConnection } from '@microsoft/signalr';
|
||||
import { ISignalRInput } from '../type';
|
||||
@@ -28,6 +28,7 @@ export class SignalRService {
|
||||
this.deadConnectionBackGround.pipe(
|
||||
switchMap(() => timer(150000)), // 2 minutes 30 seconds
|
||||
).subscribe(() => {
|
||||
console.log('trigger new connections')
|
||||
this.newConnection()
|
||||
})
|
||||
|
||||
@@ -58,7 +59,7 @@ export class SignalRService {
|
||||
const attempConnection = await connection.establishConnection()
|
||||
|
||||
if(attempConnection.isOk()) {
|
||||
|
||||
console.log('connect')
|
||||
this.connection?.closeConnection()
|
||||
this.connection = connection
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ export enum EnumSocketError {
|
||||
export class SignalRConnection {
|
||||
|
||||
private hubConnection: signalR.HubConnection;
|
||||
private messageSubject: BehaviorSubject<MessageOutPutDataDTO> = new BehaviorSubject<MessageOutPutDataDTO>(null);
|
||||
private connectionStateSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
private disconnectSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
private reconnectSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
@@ -127,7 +126,12 @@ export class SignalRConnection {
|
||||
this.hubConnection.invoke(input.method, input.data)
|
||||
|
||||
this.sendDataSubject.pipe(
|
||||
filter((message) => input.data.requestId == message?.data.requestId),
|
||||
filter((message) => {
|
||||
console.log(message)
|
||||
return input.data.requestId == message?.data.requestId ||
|
||||
input.data.roomName == message?.data.roomName
|
||||
|
||||
}),
|
||||
first()
|
||||
).subscribe(value => {
|
||||
resolve(ok(value.data as unknown as T))
|
||||
@@ -157,7 +161,6 @@ export class SignalRConnection {
|
||||
|
||||
for(const method of methods) {
|
||||
this.hubConnection.on(method, (message: any) => {
|
||||
this.messageSubject.next(message);
|
||||
this.sendDataSubject.next({
|
||||
method: method,
|
||||
data: message
|
||||
|
||||
Reference in New Issue
Block a user