attribute.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import { Observable } from "rxjs";
  2. import { MessageLog } from "../../interfaces/general.interface";
  3. abstract class RemoteSR {
  4. remoteSrId: string | undefined
  5. msgLogger: MessageLogger
  6. msgErrorLogger: MessageErrorLogger
  7. Transporter: Transporter
  8. constructor(remoteSrId: string, msgLogger: MessageLogger, msgErrorLogger: MessageErrorLogger, transporter: Transporter) {
  9. this.remoteSrId = remoteSrId
  10. this.msgLogger = msgLogger
  11. this.msgErrorLogger = msgErrorLogger
  12. this.Transporter = transporter
  13. }
  14. }
  15. abstract class RemoteSRClient extends RemoteSR {
  16. abstract RemoteSR
  17. constructor(remoteSrId: string, msgLogger: MessageLogger, msgErrorLogger: MessageErrorLogger, transporter: Transporter) {
  18. super(remoteSrId, msgLogger, msgErrorLogger, transporter)
  19. }
  20. abstract send(msg: any): Observable<any>
  21. abstract emit(msg: any)
  22. }
  23. abstract class RemoteRSClient {
  24. resObs: Observable<any>
  25. constructor(resObs: Observable<any>) {
  26. this.resObs = resObs;
  27. }
  28. }
  29. class RemoteSender extends RemoteSR {
  30. constructor(remoteSrId: string, msgLogger: MessageLogger, msgErrorLogger: MessageErrorLogger, transporter: Transporter) {
  31. super(remoteSrId, msgLogger, msgErrorLogger, transporter)
  32. }
  33. }
  34. class RemoteReceiver extends RemoteSR {
  35. receivableObs: Observable<any>
  36. constructor(remoteSrId: string, msgLogger: MessageLogger, msgErrorLogger: MessageErrorLogger, transporter: Transporter) {
  37. super(remoteSrId, msgLogger, msgErrorLogger, transporter)
  38. this.receivableObs = transporter.transporter // Assuming this is where it returns an observable
  39. }
  40. }
  41. class MessageLogger extends RemoteSR {
  42. msgId: string
  43. msg: MessageLog
  44. constructor(msgId: string, msg: MessageLog, remoteSrId: string, msgLogger: MessageLogger, msgErrorLogger: MessageErrorLogger, transporter: Transporter) {
  45. super(remoteSrId, msgLogger, msgErrorLogger, transporter)
  46. this.msgId = msgId
  47. this.msg = msg
  48. }
  49. }
  50. class MessageErrorLogger extends RemoteSR {
  51. msgId: string
  52. constructor(msgId: string, remoteSrId: string, msgLogger: MessageLogger, msgErrorLogger: MessageErrorLogger, transporter: Transporter) {
  53. super(remoteSrId, msgLogger, msgErrorLogger, transporter)
  54. this.msgId = msgId
  55. }
  56. }
  57. class Transporter extends RemoteSR {
  58. transporter: any
  59. constructor(remoteSrId: string, msgLogger: MessageLogger, msgErrorLogger: MessageErrorLogger, transporter: Transporter) {
  60. super(remoteSrId, msgLogger, msgErrorLogger, transporter)
  61. this.transporter = transporter
  62. }
  63. }
  64. class RemoteReceiverClient extends RemoteSRClient {
  65. RemoteSR: any;
  66. constructor(remoteSrId: string, msgLogger: MessageLogger, msgErrorLogger: MessageErrorLogger, transporter: Transporter) {
  67. super(remoteSrId, msgLogger, msgErrorLogger, transporter)
  68. }
  69. send(msg: any): Observable<any> {
  70. let newObservable: Observable<any> = new Observable()
  71. return newObservable
  72. }
  73. emit(msg: any) {
  74. }
  75. }
  76. class RemoteSenderClient extends RemoteSRClient {
  77. RemoteSR: any;
  78. constructor(remoteSrId: string, msgLogger: MessageLogger, msgErrorLogger: MessageErrorLogger, transporter: Transporter) {
  79. super(remoteSrId, msgLogger, msgErrorLogger, transporter)
  80. }
  81. send(msg: any): Observable<any> {
  82. let newObservable: Observable<any> = new Observable()
  83. return newObservable
  84. }
  85. emit(msg: any) {
  86. }
  87. }
  88. class RemoteRSReceiverClient extends RemoteRSClient {
  89. observables: Observable<any>[]
  90. constructor(resObs: Observable<any>, observables: Observable<any>[]) {
  91. super(resObs)
  92. this.observables = observables
  93. }
  94. addObs(obs: Observable<any>) { }
  95. }
  96. class RemoteRSSenderClient extends RemoteRSClient {
  97. receiver: any
  98. constructor(resObs: Observable<any>, receiver: any) {
  99. super(resObs)
  100. this.receiver = receiver
  101. }
  102. }