mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
add endpoint
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { BehaviorSubject, Subject, timer } from 'rxjs';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { SignalRConnection } from './signalR';
|
||||
import { Plugins } from '@capacitor/core';
|
||||
@@ -7,6 +7,7 @@ import { UserTypingDTO } from '../../data/dto/typing/typingInputDTO';
|
||||
import { MessageOutPutDataDTO } from '../../data/dto/message/messageOutputDTO';
|
||||
import { MessageDeleteInputDTO } from '../../data/dto/message/messageDeleteInputDTO';
|
||||
import { object, z } from 'zod';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
|
||||
const { App } = Plugins;
|
||||
|
||||
@@ -32,27 +33,34 @@ export class SignalRService {
|
||||
private messageUpdateSubject: BehaviorSubject<MessageOutPutDataDTO> = new BehaviorSubject<MessageOutPutDataDTO>(null);
|
||||
private sendDataSubject: BehaviorSubject<Object> = new BehaviorSubject<Object>(false);
|
||||
|
||||
private deadConnectionBackGround: Subject<any>;
|
||||
|
||||
constructor(
|
||||
private platform: Platform) {
|
||||
// this.startConnection();
|
||||
// this.addMessageListener();
|
||||
constructor(private platform: Platform) {
|
||||
|
||||
|
||||
this.deadConnectionBackGround = new Subject()
|
||||
this.deadConnectionBackGround.pipe(
|
||||
switchMap(() => timer(300000)),
|
||||
).subscribe(() => {
|
||||
this.newConnection()
|
||||
})
|
||||
|
||||
try {
|
||||
if (!this.platform.is('desktop')) {
|
||||
App.addListener('appStateChange', ({ isActive }) => {
|
||||
if (isActive) {
|
||||
// The app is in the foreground.
|
||||
console.log('App is in the foreground');
|
||||
// console.log('App is in the foreground');
|
||||
this.deadConnectionBackGround.next()
|
||||
|
||||
this.newConnection()
|
||||
|
||||
} else {
|
||||
// The app is in the background.
|
||||
console.log('App is in the background');
|
||||
// You can perform actions specific to the background state here.
|
||||
}
|
||||
});
|
||||
} else {
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
this.deadConnectionBackGround.next()
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch(error) {}
|
||||
|
||||
@@ -75,6 +83,7 @@ export class SignalRService {
|
||||
})
|
||||
|
||||
this.connection.getMessages().subscribe((data) => {
|
||||
console.log("receive message 55")
|
||||
this.messageSubject.next(data)
|
||||
})
|
||||
this.connection.getTyping().subscribe((data) => {
|
||||
@@ -89,12 +98,9 @@ export class SignalRService {
|
||||
this.messageUpdateSubject.next(data)
|
||||
})
|
||||
|
||||
this.connection.getMessageUpdateSubject().subscribe((data) => {
|
||||
this.messageUpdateSubject.next(data)
|
||||
})
|
||||
|
||||
this.connection.getData().subscribe((data) => {
|
||||
this.messageUpdateSubject.next(data)
|
||||
this.sendDataSubject.next(data)
|
||||
this.deadConnectionBackGround.next()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user