12345678910111213141516171819202122232425262728293031323334 |
- import { map, Observable, of, tap } from "rxjs";
- import { BaseMessage, Command, ResponseMessage, Uuid } from "../dependencies/fisappmessagejsutilty/interface/export"
- import { LoggingService } from "../dependencies/fisloggingservice/services/logging-service";
- import { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype";
- import { IncomingMessageServiceInterface } from "../type/datatype";
- import { AcknowledgementService } from "./acknowledgement.service";
- export class IncomingMessageService implements IncomingMessageServiceInterface {
- constructor(private logService?: LoggingService, private acknowledgeService?: AcknowledgementService) {
- this.logService = new LoggingService()
- this.acknowledgeService = new AcknowledgementService()
- }
- init(settings: LogSetting & { incomingObservable: Observable<BaseMessage>; }): void {
- let logSetting: LogSetting = {
- storage: settings.storage,
- setting: settings.setting,
- customSetting: settings.customSetting
- }
- // Transform incoming observables into Observable<MessageLog> to be logged
- let transformedOBS: Observable<any> = settings.incomingObservable.pipe(
- map(
- messages => (messages.data)
- )
- )
- this.logService.init(logSetting).then(() => {
- this.logService.subscribe(transformedOBS)
- }).then(() => {
- this.acknowledgeService.init(logSetting).then(() => {
- this.acknowledgeService.subscribe(transformedOBS)
- }).catch((e) => console.error(e))
- }).catch((e) => console.error(e))
- }
- }
|