ad monitoring

This commit is contained in:
Peter Maquiran
2024-08-21 11:37:47 +01:00
parent d76f2e240e
commit 82c67b8976
5 changed files with 51 additions and 19 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ export class ChatModule {
connection.subscribe((value) => {
if(value) {
// on connect
this.ChatServiceService.sendLocalMessages()
// this.ChatServiceService.sendLocalMessages()
}
})
@@ -45,7 +45,7 @@ export class MessageCreateUseCaseService {
) { }
@XTracerAsync({name:'MessageCreateUseCaseService', module:'chat', bugPrint: true})
@XTracerAsync({name:'MessageCreateUseCaseService', module:'chat', bugPrint: true, waitNThrow: 5000})
async execute(message: MessageEntity, messageEnum: RoomType, tracing?: TracingType) {
const validation = zodSafeValidation<MessageEntity>(MessageEntitySchema, message)
@@ -45,29 +45,29 @@ export class SendLocalMessagesUseCaseService {
console.log('to upload', messages)
const requestId = InstanceId +'@'+ uuidv4();
const DTO = MessageMapper.fromDomain(message, requestId)
await this.messageLocalDataSourceService.update(message.$id, { sending: true })
const sendMessageResult = await this.messageLiveSignalRDataSourceService.sendMessage<MessageOutPutDataDTO>(DTO)
if(sendMessageResult.isOk()) {
if(sendMessageResult.value.sender == undefined || sendMessageResult.value.sender == null) {
delete sendMessageResult.value.sender
}
let clone: MessageTable = {
...sendMessageResult.value,
id: sendMessageResult.value.id,
$id : message.$id
}
console.log('send message local '+ messages.length)
this.messageLocalDataSourceService.update(message.$id, {...clone, sending: false, roomId: message.roomId})
} else {
console.log('erro send message')
console.log('erro send message', sendMessageResult.error)
this.messageLocalDataSourceService.update(message.$id, {sending: false})
}
}
+23 -1
View File
@@ -1,5 +1,5 @@
import * as signalR from '@microsoft/signalr';
import { BehaviorSubject, Observable } from 'rxjs';
import { BehaviorSubject, Observable, race, timer } from 'rxjs';
import { ok, Result, err } from 'neverthrow';
import { SessionStore } from 'src/app/store/session.service';
import { filter, first } from 'rxjs/operators';
@@ -232,6 +232,28 @@ export class SignalRConnection {
resolve(ok(value));
});
// // Create an observable for the timeout (8 seconds)
// const timeout$ = timer(8000);
// // Create an observable for the message
// const message$ = this.messageUPdateSubject.pipe(
// filter((message: MessageOutPutDataDTO) => requestId === message?.requestId),
// first()
// );
// // Use race to choose whichever completes first (either the message or the timeout)
// race(message$, timeout$).subscribe({
// next: (value) => {
// if (typeof value === 'number') {
// // If the value is a number, it means the timeout fired
// reject(err('No response, timeout'));
// } else {
// resolve(ok(value));
// }
// },
// error: (error) => reject(err('Error: ' + error))
// });
} else {
this.sendLaterSubject.next({method: 'SendMessage', args: data})
return reject(err(false))