mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
receive message live
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { MessageLiveDataSourceService } from '../../data-source/message/message-live-data-source.service';
|
||||
import { MessageLocalDataSourceService } from '../../data-source/message/message-local-data-source.service';
|
||||
import { IncomingMessageSchema, MessageLocalDataSourceService } from '../../data-source/message/message-local-data-source.service';
|
||||
import { MessageRemoteDataSourceService } from '../../data-source/message/message-remote-data-source.service';
|
||||
import { SignalRService } from '../../../infra/socket/signal-r.service';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { InstanceId } from '../../repository/message-respository.service';
|
||||
import { SocketStreamReturn } from 'src/app/services/decorators/socket-validate-schema.decorator';
|
||||
import { SafeValidateSchema } from 'src/app/services/decorators/validate-schema.decorator';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -26,25 +28,33 @@ export class MessageAsyncService {
|
||||
).subscribe(async (message: any) => {
|
||||
|
||||
console.log('message async ', message)
|
||||
const id = message.id
|
||||
|
||||
const id = message.id + ''
|
||||
delete message.id;
|
||||
|
||||
const result = await this.messageLocalDataSourceService.createMessage({
|
||||
const incomingMessage = {
|
||||
...message,
|
||||
messageId: id,
|
||||
sending: false,
|
||||
...message
|
||||
})
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
console.log(result.value)
|
||||
console.log("nice send receive")
|
||||
|
||||
} else {
|
||||
console.log(result.error)
|
||||
roomId:message.chatRoomId
|
||||
}
|
||||
|
||||
this.incomingMessage(incomingMessage)
|
||||
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@SafeValidateSchema(IncomingMessageSchema, 'socket/incomingMessage')
|
||||
async incomingMessage(IncomingMessageSchema: any) {
|
||||
|
||||
const result = await this.messageLocalDataSourceService.sendMessage(IncomingMessageSchema)
|
||||
|
||||
if(result.isOk()) {
|
||||
|
||||
} else {
|
||||
console.log(result.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user