浏览代码

acknowledgement fix

Enzo 1 年之前
父节点
当前提交
d076edf671
共有 6 个文件被更改,包括 92 次插入31 次删除
  1. 6 1
      .gitignore
  2. 0 9
      interface/acknowledgement.interface.ts
  3. 5 0
      interface/export.ts
  4. 1 1
      package.json
  5. 54 20
      services/acknowledgemeent.service.ts
  6. 26 0
      type/acknowledgement.interface.ts

+ 6 - 1
.gitignore

@@ -1,3 +1,8 @@
 node_modules
 *.js.map
-*.js
+*.js
+appLocation.json
+appLogLoc.json
+appProfile.json
+log.json
+loglocation.json

+ 0 - 9
interface/acknowledgement.interface.ts

@@ -1,9 +0,0 @@
-import { Observable } from "rxjs";
-import { ResponseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
-import { LogSetting } from "../dependencies/fisloggingservice/type/datatype";
-
-export interface Acknowledgemeent {
-    init(settings: LogSetting): void;
-
-    subscribe(obs: Observable<string>): Observable<ResponseMessage>
-}

+ 5 - 0
interface/export.ts

@@ -0,0 +1,5 @@
+
+// All service classes to be exported will be set here.
+export * from "../services/acknowledgemeent.service"
+export * from "../services/synchronization.service"
+ 

+ 1 - 1
package.json

@@ -4,7 +4,7 @@
   "description": "",
   "main": "index.js",
   "scripts": {
-    "build": "tsc -p ",
+    "build": "tsc -p tsconfig-json",
     "start": "node test/test.js",
     "test": "echo \"Error: no test specified\" && exit 1"
   },

+ 54 - 20
services/acknowledgemeent.service.ts

@@ -1,15 +1,28 @@
-import { map, Observable, tap } from "rxjs";
-import { ResponseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
-import { FisCreateMessageUtility } from "../dependencies/fisappmessagejsutilty/services/fis.create.message";
+import { AnyObject } from "mongoose";
+import { map, Observable, of, tap } from "rxjs";
+import { Command, ResponseMessage } from "../dependencies/fisappmessagejsutilty/interface/export"
+import { FisCreateMessageUtility } from "../dependencies/fisappmessagejsutilty/interface/export";
 import { LoggingService } from "../dependencies/fisloggingservice/services/logging-service";
 import { LogSetting } from "../dependencies/fisloggingservice/type/datatype";
-import { Acknowledgemeent } from "../interface/acknowledgement.interface";
+import { Acknowledgemeent, AcknowledgementLogSetting } from "../type/acknowledgement.interface";
 
 
 export class AcknowledgementService implements Acknowledgemeent {
 
     private messageUtil: FisCreateMessageUtility = new FisCreateMessageUtility("FisAppID/Name")
-    private settings: LogSetting = {
+    private settings1: LogSetting = {
+        storage: '',
+        setting: {
+            appId: '',
+            appName: '',
+            logLocName: '',
+            logLocId: '',
+            appLogLocId: '',
+            appLocName: '',
+            appLogId: ''
+        }
+    }
+    private settings2: LogSetting = {
         storage: '',
         setting: {
             appId: '',
@@ -22,30 +35,51 @@ export class AcknowledgementService implements Acknowledgemeent {
         }
     }
 
-    constructor(private logService?: LoggingService) {
+    constructor(private logService1?: LoggingService, private logService2?: LoggingService) {
+        this.logService1 = new LoggingService()
+        this.logService2 = new LoggingService()
     }
 
     // set the data. I dont know what to set yet
-    public async init(settings: LogSetting) {
+    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.settings = settings
-        this.logService.init(this.settings)
-        // Error Cannot error properties of undefined (reading 'init')
+        this.settings1 = logSetting1
+        this.logService1.init(logSetting1)
+        this.settings2 = logSetting2
+        this.logService2.init(logSetting2)
     }
 
     // suppose to call logging service to give an observable type report for every message streamed
     public subscribe(obs: Observable<any>): Observable<ResponseMessage> {
-        obs.subscribe((data) => {
-            // console.log(data)
-            this.logService.subscribe(data)
-        })
-        let acknowledgementToken = obs.pipe(
+        this.logService1.subscribe(obs)
+        let acknowledgementToken: Observable<ResponseMessage> = obs.pipe(
             map(
-                acknowledgement => acknowledgement
-                // acknowledement =>  this.utilMessage.getResponseMessage(Parameters to be discussed)
-                // this.logService(acknowledgement)
+                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
+                }
+
             ))
-        this.logService.subscribe(acknowledgementToken) // Only log MessageObservable Type. Cannot log acknowledgement
-        return acknowledgementToken// return response Message
+        this.logService2.subscribe(acknowledgementToken) 
+        return acknowledgementToken
     }
 }

+ 26 - 0
type/acknowledgement.interface.ts

@@ -0,0 +1,26 @@
+import { Observable } from "rxjs";
+import { ResponseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
+import { LogSetting } from "../dependencies/fisloggingservice/type/datatype";
+
+export interface Acknowledgemeent {
+    init(settings: LogSetting): void;
+
+    subscribe(obs: Observable<string>): Observable<ResponseMessage>
+}
+
+export type AcknowledgementLogSetting = {
+    storage: string;
+    setting?: {
+        appId?: string,
+        appName: string
+    }
+
+    customSetting?: {
+        srv?: boolean,
+        user?: string,
+        password?: string,
+        server?: string,
+        collection?: string
+        url?: string // Full link if possible. Doesnt matter cloud or remote server
+    }
+}