import { AnyObject } from "mongoose"; import { map, Observable, of, tap } from "rxjs"; import { Command, ResponseMessage, Uuid } from "../dependencies/fisappmessagejsutilty/interface/export" import { FisCreateMessageUtility } from "../dependencies/fisappmessagejsutilty/interface/export"; import { LoggingService } from "../dependencies/fisloggingservice/services/logging-service"; import { LogSetting, MessageLog } from "../dependencies/fisloggingservice/type/datatype"; import { Acknowledgemeent, AcknowledgementLogSetting } from "../type/acknowledgement.interface"; export class AcknowledgementService implements Acknowledgemeent { private messageUtil: FisCreateMessageUtility = new FisCreateMessageUtility("FisAppID/Name") private settings2: LogSetting = { storage: '', setting: { appId: '', appName: '', logLocName: '', logLocId: '', appLogLocId: '', appLocName: '', appLogId: '' } } constructor(private logService1?: LoggingService, private logService2?: LoggingService) { // this.logService1 = new LoggingService() this.logService2 = new LoggingService() } public async init(settings: AcknowledgementLogSetting) { // let logSetting1: LogSetting = { // ...settings, // setting: { // ...settings.setting, // logLocName: "locationName1", // appLocName: "appLocName1" // } // } let logSetting2: LogSetting = { ...settings, setting: { ...settings.setting, logLocName: "locationName2", appLocName: "appLocName2" } } // console.log(settings) // this.settings1 = logSetting1 // this.logService1.init(logSetting1) this.settings2 = logSetting2 this.logService2.init(logSetting2) } public subscribe(obs: Observable): Observable { let acknowledgementToken: Observable = obs.pipe( map( incoming_msg => { let emulatedId = "GeneratedFromMessageSync" let emulatedRequest = this.messageUtil.getCommandMessage(emulatedId, Command.New, incoming_msg) let finalResponse = this.messageUtil.getResponseMessage(emulatedId, { "Acknowledgement": 1 }, emulatedRequest) return finalResponse } )) let acknowledgementTokenLogging: Observable = obs.pipe( map( incoming_msg => { let finalResponse:MessageLog = { appLogLocId: this.settings2.setting.appLogId, appData: { msgId: new Uuid().generateId(), msgLogDateTime: new Date(), msgDateTime: new Date(), msgTag: ['Acknowledgement'], msgPayload: JSON.stringify(incoming_msg) } } return finalResponse } ) ) this.logService2.subscribe(acknowledgementTokenLogging) return acknowledgementToken } }