synchronization.service.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { Observable, Subject } from "rxjs";
  2. import { BaseMessage } from "../dependencies/fisappmessagejsutilty/dependencies/dependencies";
  3. import { LoggingService } from "../dependencies/fisloggingservice/services/logging-service";
  4. import { MessageSynchronisationServiceInterface, MessageSynchronisationServiceSetting } from "../type/datatype";
  5. export class MessageSyncrhonizationService implements MessageSynchronisationServiceInterface {
  6. settings:MessageSynchronisationServiceSetting
  7. sourceSrc:LoggingService = new LoggingService()
  8. targetSrc:LoggingService = new LoggingService()
  9. public async init(settings: MessageSynchronisationServiceSetting): Promise<void> {
  10. console.log(settings)
  11. this.settings = settings;
  12. this.sourceSrc.init(settings.incomingSource);
  13. this.targetSrc.init(settings.target);
  14. }
  15. public subscribe(obs: Observable<string>): Observable<any> {
  16. let returnObs:Subject<BaseMessage> = new Subject();
  17. // filter all source tags[0] log data
  18. // this.logSrv1.filter(
  19. // this.settings.incomingSource.tags[0]
  20. // ) = set1
  21. // filter all target tags[0] log data
  22. // this.logSrv2.filter(
  23. // this.settings.target.tags[0]
  24. // ) = set2
  25. // Compare set1 and set2
  26. // >> found missing message "4"
  27. // Send missing messages "4" ( in a loop)
  28. //returnObs.next(message "4")
  29. obs.subscribe(
  30. {
  31. next:(data)=>{
  32. // filter all source tags[0] log data
  33. // this.logSrv1.filter(
  34. // this.settings.incomingSource.tags[0]
  35. // ) = set1
  36. // filter all target tags[0] log data
  37. // this.logSrv2.filter(
  38. // this.settings.target.tags[0]
  39. // ) = set2
  40. // Compare set1 and set2
  41. // >> found missing message "5x"
  42. // Send missing messages "5x" ( in a loop)
  43. //returnObs.next(message "5x")
  44. }
  45. }
  46. )
  47. console.log(obs)
  48. return
  49. }
  50. }