1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 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()
- }
- public 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))
- )
- /* Trying new promise chaining structure */
- this.logService.init(logSetting).then(() => {
- this.logService.subscribe(transformedOBS)
- }).catch((e) => console.error(e)).then(() => {
- this.acknowledgeService.init(logSetting)
- }).catch((e) => console.error(e)).then(() => {
- this.acknowledgeService.subscribe(transformedOBS)
- }).catch((e) => console.error(e))
- // 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.log(e))
- // }).catch((e) => console.error(e))
- }
- }
|