@futdevpro/nts-dynamo 1.5.76 → 1.5.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/LICENSE +2 -2
  2. package/lib/_constants/dynamo-nts-global-settings.d.ts +2 -2
  3. package/lib/_constants/dynamo-nts-global-settings.js +17 -17
  4. package/lib/_constants/index.d.ts +1 -1
  5. package/lib/_constants/index.js +4 -4
  6. package/lib/_enums/data-model-type.enum.d.ts +12 -12
  7. package/lib/_enums/data-model-type.enum.js +16 -16
  8. package/lib/_enums/data-model-type.enum.js.map +1 -1
  9. package/lib/_enums/dynamo-nts-data-service-function.enum.d.ts +12 -12
  10. package/lib/_enums/dynamo-nts-data-service-function.enum.js +18 -18
  11. package/lib/_enums/dynamo-nts-data-service-function.enum.js.map +1 -1
  12. package/lib/_enums/dynamo-nts-route-security.enum.d.ts +11 -11
  13. package/lib/_enums/dynamo-nts-route-security.enum.js +15 -15
  14. package/lib/_enums/dynamo-nts-route-security.enum.js.map +1 -1
  15. package/lib/_enums/dynamo-nts-socket-security.enum.d.ts +10 -10
  16. package/lib/_enums/dynamo-nts-socket-security.enum.js +14 -14
  17. package/lib/_enums/dynamo-nts-socket-security.enum.js.map +1 -1
  18. package/lib/_enums/http/http-call-type.enum.d.ts +11 -11
  19. package/lib/_enums/http/http-call-type.enum.js +15 -15
  20. package/lib/_enums/http/http-call-type.enum.js.map +1 -1
  21. package/lib/_enums/http/http-response-type.enum.d.ts +6 -6
  22. package/lib/_enums/http/http-response-type.enum.js +10 -10
  23. package/lib/_enums/http/http-response-type.enum.js.map +1 -1
  24. package/lib/_enums/http/socket-event.enum.d.ts +9 -8
  25. package/lib/_enums/http/socket-event.enum.d.ts.map +1 -1
  26. package/lib/_enums/http/socket-event.enum.js +13 -12
  27. package/lib/_enums/http/socket-event.enum.js.map +1 -1
  28. package/lib/_enums/index.d.ts +8 -8
  29. package/lib/_enums/index.js +13 -13
  30. package/lib/_enums/predefined-data-types.enum.d.ts +10 -10
  31. package/lib/_enums/predefined-data-types.enum.js +14 -14
  32. package/lib/_enums/predefined-data-types.enum.js.map +1 -1
  33. package/lib/_interfaces/certification-settings.interface.d.ts +7 -0
  34. package/lib/_interfaces/certification-settings.interface.d.ts.map +1 -0
  35. package/lib/_interfaces/certification-settings.interface.js +3 -0
  36. package/lib/_interfaces/certification-settings.interface.js.map +1 -0
  37. package/lib/_interfaces/global-service-settings.interface.d.ts +18 -0
  38. package/lib/_interfaces/global-service-settings.interface.d.ts.map +1 -0
  39. package/lib/_interfaces/global-service-settings.interface.js +3 -0
  40. package/lib/_interfaces/global-service-settings.interface.js.map +1 -0
  41. package/lib/_interfaces/index.d.ts +1 -0
  42. package/lib/_interfaces/index.d.ts.map +1 -0
  43. package/lib/_interfaces/index.js +4 -0
  44. package/lib/_interfaces/index.js.map +1 -0
  45. package/lib/_interfaces/port-settings.interface.d.ts +5 -0
  46. package/lib/_interfaces/port-settings.interface.d.ts.map +1 -0
  47. package/lib/_interfaces/port-settings.interface.js +3 -0
  48. package/lib/_interfaces/port-settings.interface.js.map +1 -0
  49. package/lib/_models/dynamo-nts-api-call-params.d.ts +95 -95
  50. package/lib/_models/dynamo-nts-api-call-params.js +47 -47
  51. package/lib/_models/dynamo-nts-app-params.d.ts +49 -49
  52. package/lib/_models/dynamo-nts-app-params.js +17 -17
  53. package/lib/_models/dynamo-nts-endpoint-params.d.ts +80 -80
  54. package/lib/_models/dynamo-nts-endpoint-params.js +139 -139
  55. package/lib/_models/dynamo-nts-global-settings.d.ts +53 -53
  56. package/lib/_models/dynamo-nts-global-settings.js +2 -2
  57. package/lib/_models/dynamo-nts-routing-module-settings.d.ts +19 -19
  58. package/lib/_models/dynamo-nts-routing-module-settings.js +2 -2
  59. package/lib/_models/dynamo-nts-socket-event-params.d.ts +32 -30
  60. package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
  61. package/lib/_models/dynamo-nts-socket-event-params.js +80 -79
  62. package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
  63. package/lib/_models/dynamo-nts-socket-presence.d.ts +21 -0
  64. package/lib/_models/dynamo-nts-socket-presence.d.ts.map +1 -0
  65. package/lib/_models/dynamo-nts-socket-presence.js +45 -0
  66. package/lib/_models/dynamo-nts-socket-presence.js.map +1 -0
  67. package/lib/_models/dynamo-nts-socket-service-params.d.ts +18 -18
  68. package/lib/_models/dynamo-nts-socket-service-params.d.ts.map +1 -1
  69. package/lib/_models/dynamo-nts-socket-service-params.js +26 -26
  70. package/lib/_models/dynamo-nts-socket-service-params.js.map +1 -1
  71. package/lib/_models/index.d.ts +7 -8
  72. package/lib/_models/index.d.ts.map +1 -1
  73. package/lib/_models/index.js +12 -12
  74. package/lib/_models/index.js.map +1 -1
  75. package/lib/_modules/api-service.index.d.ts +5 -5
  76. package/lib/_modules/api-service.index.js +11 -11
  77. package/lib/_modules/app-extended.index.d.ts +15 -12
  78. package/lib/_modules/app-extended.index.d.ts.map +1 -1
  79. package/lib/_modules/app-extended.index.js +23 -19
  80. package/lib/_modules/app-extended.index.js.map +1 -1
  81. package/lib/_modules/app.index.d.ts +13 -10
  82. package/lib/_modules/app.index.d.ts.map +1 -1
  83. package/lib/_modules/app.index.js +21 -17
  84. package/lib/_modules/app.index.js.map +1 -1
  85. package/lib/_modules/auth.index.d.ts +3 -3
  86. package/lib/_modules/auth.index.js +8 -8
  87. package/lib/_modules/constants.index.d.ts +1 -1
  88. package/lib/_modules/constants.index.js +4 -4
  89. package/lib/_modules/controller.index.d.ts +4 -4
  90. package/lib/_modules/controller.index.js +10 -10
  91. package/lib/_modules/custom-data/custom-data.controller.d.ts +5 -5
  92. package/lib/_modules/custom-data/custom-data.controller.js +55 -55
  93. package/lib/_modules/custom-data/custom-data.service.d.ts +5 -5
  94. package/lib/_modules/custom-data/custom-data.service.js +11 -11
  95. package/lib/_modules/custom-data/get-custom-data-routing-module.d.ts +3 -3
  96. package/lib/_modules/custom-data/get-custom-data-routing-module.js +17 -17
  97. package/lib/_modules/custom-data/index.d.ts +4 -4
  98. package/lib/_modules/custom-data/index.js +8 -8
  99. package/lib/_modules/custom-data-module.index.d.ts +1 -1
  100. package/lib/_modules/custom-data-module.index.js +4 -4
  101. package/lib/_modules/data-service.index.d.ts +5 -5
  102. package/lib/_modules/data-service.index.js +10 -10
  103. package/lib/_modules/email.index.d.ts +3 -3
  104. package/lib/_modules/email.index.js +8 -8
  105. package/lib/_modules/enums.index.d.ts +1 -1
  106. package/lib/_modules/enums.index.js +4 -4
  107. package/lib/_modules/models.index.d.ts +1 -1
  108. package/lib/_modules/models.index.js +4 -4
  109. package/lib/_modules/services.index.d.ts +1 -1
  110. package/lib/_modules/services.index.js +4 -4
  111. package/lib/_modules/test/get-test-routing-module.d.ts +3 -3
  112. package/lib/_modules/test/get-test-routing-module.js +17 -17
  113. package/lib/_modules/test/index.d.ts +3 -3
  114. package/lib/_modules/test/index.js +7 -7
  115. package/lib/_modules/test/test.controller.d.ts +5 -5
  116. package/lib/_modules/test/test.controller.js +104 -104
  117. package/lib/_modules/test-module.index.d.ts +1 -1
  118. package/lib/_modules/test-module.index.js +4 -4
  119. package/lib/_modules/usage/get-usage-routing-module.d.ts +3 -3
  120. package/lib/_modules/usage/get-usage-routing-module.js +17 -17
  121. package/lib/_modules/usage/index.d.ts +4 -4
  122. package/lib/_modules/usage/index.js +8 -8
  123. package/lib/_modules/usage/usage-controller.d.ts +6 -6
  124. package/lib/_modules/usage/usage-controller.js +88 -88
  125. package/lib/_modules/usage/usage.service.d.ts +16 -16
  126. package/lib/_modules/usage/usage.service.js +132 -132
  127. package/lib/_modules/usage-module.index.d.ts +1 -1
  128. package/lib/_modules/usage-module.index.js +4 -4
  129. package/lib/_services/dynamo-nts-api.service.d.ts +34 -34
  130. package/lib/_services/dynamo-nts-api.service.js +188 -188
  131. package/lib/_services/dynamo-nts-app-extended.d.ts +128 -128
  132. package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
  133. package/lib/_services/dynamo-nts-app-extended.js +212 -212
  134. package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
  135. package/lib/_services/dynamo-nts-app.d.ts +270 -278
  136. package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
  137. package/lib/_services/dynamo-nts-app.js +371 -371
  138. package/lib/_services/dynamo-nts-app.js.map +1 -1
  139. package/lib/_services/dynamo-nts-app.spec.d.ts +1 -0
  140. package/lib/_services/dynamo-nts-app.spec.d.ts.map +1 -0
  141. package/lib/_services/dynamo-nts-app.spec.js +10 -0
  142. package/lib/_services/dynamo-nts-app.spec.js.map +1 -0
  143. package/lib/_services/dynamo-nts-auth.service.d.ts +127 -127
  144. package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
  145. package/lib/_services/dynamo-nts-auth.service.js +53 -53
  146. package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
  147. package/lib/_services/dynamo-nts-controller.service.d.ts +105 -105
  148. package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
  149. package/lib/_services/dynamo-nts-controller.service.js +57 -57
  150. package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
  151. package/lib/_services/dynamo-nts-data.service.d.ts +230 -229
  152. package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
  153. package/lib/_services/dynamo-nts-data.service.js +689 -686
  154. package/lib/_services/dynamo-nts-data.service.js.map +1 -1
  155. package/lib/_services/dynamo-nts-db-service-collection.service.d.ts +8 -8
  156. package/lib/_services/dynamo-nts-db-service-collection.service.js +10 -10
  157. package/lib/_services/dynamo-nts-db.service.d.ts +312 -312
  158. package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
  159. package/lib/_services/dynamo-nts-db.service.js +856 -856
  160. package/lib/_services/dynamo-nts-db.service.js.map +1 -1
  161. package/lib/_services/dynamo-nts-email-service-collection.service.d.ts +18 -18
  162. package/lib/_services/dynamo-nts-email-service-collection.service.js +20 -20
  163. package/lib/_services/dynamo-nts-email.service.d.ts +56 -56
  164. package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
  165. package/lib/_services/dynamo-nts-email.service.js +203 -203
  166. package/lib/_services/dynamo-nts-email.service.js.map +1 -1
  167. package/lib/_services/dynamo-nts-global.service.d.ts +71 -84
  168. package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
  169. package/lib/_services/dynamo-nts-global.service.js +156 -156
  170. package/lib/_services/dynamo-nts-global.service.js.map +1 -1
  171. package/lib/_services/dynamo-nts-routing-module.service.d.ts +76 -76
  172. package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
  173. package/lib/_services/dynamo-nts-routing-module.service.js +191 -191
  174. package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
  175. package/lib/_services/dynamo-nts-shared.service.d.ts +31 -31
  176. package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -1
  177. package/lib/_services/dynamo-nts-shared.service.js +70 -70
  178. package/lib/_services/dynamo-nts-shared.service.js.map +1 -1
  179. package/lib/_services/dynamo-nts-shared.service.spec.d.ts +2 -0
  180. package/lib/_services/dynamo-nts-shared.service.spec.d.ts.map +1 -0
  181. package/lib/_services/dynamo-nts-shared.service.spec.js +12 -0
  182. package/lib/_services/dynamo-nts-shared.service.spec.js.map +1 -0
  183. package/lib/_services/dynamo-nts-singleton.service.d.ts +8 -8
  184. package/lib/_services/dynamo-nts-singleton.service.js +18 -18
  185. package/lib/_services/dynamo-nts-singleton.service.js.map +1 -1
  186. package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts +9 -9
  187. package/lib/_services/dynamo-nts-socket-service-collection.service.js +13 -13
  188. package/lib/_services/dynamo-nts-socket.service.d.ts +57 -45
  189. package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
  190. package/lib/_services/dynamo-nts-socket.service.js +188 -165
  191. package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
  192. package/lib/_services/index.d.ts +14 -16
  193. package/lib/_services/index.d.ts.map +1 -1
  194. package/lib/_services/index.js +20 -20
  195. package/lib/_services/index.js.map +1 -1
  196. package/lib/index.d.ts +6 -6
  197. package/lib/index.js +14 -14
  198. package/lib/tsconfig.tsbuildinfo +1 -1
  199. package/package SAVE.json +216 -0
  200. package/package-NEW with test but not working.json +228 -0
  201. package/package.json +15 -8
  202. package/spec/support/jasmine.json +14 -0
  203. package/src/_enums/http/socket-event.enum.ts +2 -1
  204. package/src/_interfaces/certification-settings.interface.ts +7 -0
  205. package/src/_interfaces/global-service-settings.interface.ts +23 -0
  206. package/src/_interfaces/index.ts +5 -0
  207. package/src/_interfaces/port-settings.interface.ts +5 -0
  208. package/src/_models/dynamo-nts-socket-event-params.ts +23 -21
  209. package/src/_models/{dynamo-nts-socket-dictionary.ts → dynamo-nts-socket-presence.ts} +21 -5
  210. package/src/_models/dynamo-nts-socket-service-params.ts +1 -0
  211. package/src/_models/index.ts +2 -2
  212. package/src/_modules/app-extended.index.ts +7 -2
  213. package/src/_modules/app.index.ts +5 -0
  214. package/src/_services/dynamo-nts-app-extended.ts +6 -2
  215. package/src/_services/dynamo-nts-app.spec.ts +14 -0
  216. package/src/_services/dynamo-nts-app.ts +8 -14
  217. package/src/_services/dynamo-nts-auth.service.ts +1 -0
  218. package/src/_services/dynamo-nts-controller.service.ts +2 -1
  219. package/src/_services/dynamo-nts-data.service.ts +16 -10
  220. package/src/_services/dynamo-nts-db.service.ts +8 -5
  221. package/src/_services/dynamo-nts-email.service.ts +1 -0
  222. package/src/_services/dynamo-nts-global.service.ts +3 -18
  223. package/src/_services/dynamo-nts-routing-module.service.ts +1 -0
  224. package/src/_services/dynamo-nts-shared.service.spec.ts +10 -0
  225. package/src/_services/dynamo-nts-shared.service.ts +2 -1
  226. package/src/_services/dynamo-nts-socket.service.ts +80 -41
  227. package/src/_services/index.ts +2 -2
@@ -1,20 +1,21 @@
1
1
 
2
2
  import * as SocketIO from 'socket.io';
3
3
 
4
- import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
4
+ import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
5
+
6
+ import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
5
7
  import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
6
- import { DynamoNTS_SocketEventParams } from '../_models/dynamo-nts-socket-event-params';
8
+ import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
9
+ import { DynamoNTS_SocketEventParams, DynamoNTS_SocketEventPreprocessTask, DynamoNTS_SocketEventTask } from '../_models/dynamo-nts-socket-event-params';
7
10
  import { DynamoNTS_SocketEvent } from '../_enums/http/socket-event.enum';
8
- import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
9
- import { Dynamo_Error, Dynamo_Log } from '@futdevpro/fsm-dynamo';
10
11
  import { DynamoNTS_SocketServiceParams } from '../_models/dynamo-nts-socket-service-params';
11
- import { DynamoNTS_SocketDictionary } from '../_models/dynamo-nts-socket-dictionary';
12
+ import { DynamoNTS_SocketPresence } from '../_models/dynamo-nts-socket-presence';
12
13
  import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.enum';
13
14
 
14
15
  /**
15
16
  *
16
17
  */
17
- export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictionary> extends DynamoNTS_SingletonService {
18
+ export abstract class DynamoNTS_SocketService<T_Presence extends DynamoNTS_SocketPresence, T_Content = any> extends DynamoNTS_SingletonService {
18
19
  protected params: DynamoNTS_SocketServiceParams;
19
20
  get name(): string { return this.params.name; }
20
21
  get port(): number { return this.params.port; }
@@ -26,8 +27,11 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
26
27
  protected incomingEvents: DynamoNTS_SocketEventParams<any>[];
27
28
 
28
29
  private subscriptionEvent: DynamoNTS_SocketEventParams<any>;
29
- private getDicFromSubscrioption?: (content: any) => Promise<T>;
30
- protected activeSockets: T[] = [];
30
+ /**
31
+ * You need to setup a function that converts subscription event content to presence
32
+ */
33
+ protected getPresenceFromSubscrioptionEventContent?: (socketSubscription: T_Content) => Promise<T_Presence>;
34
+ protected presences: T_Presence[] = [];
31
35
 
32
36
  protected log: boolean = dynamoNTS_GlobalSettings.logSetup;
33
37
 
@@ -39,8 +43,8 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
39
43
  super();
40
44
 
41
45
  try {
42
- this.setupServiceParams();
43
- this.setupEvents();
46
+ this.params = this.getServiceParams();
47
+ this.incomingEvents = this.getIncomingEvents() ?? [];
44
48
 
45
49
  this.attachToGlobalCollection();
46
50
  this.prepareEvents();
@@ -70,15 +74,22 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
70
74
  }
71
75
  this.connectEvent.socketName = this.params.name;
72
76
 
73
- if (this.getDicFromSubscrioption) {
77
+ if (this.getPresenceFromSubscrioptionEventContent) {
74
78
  const subscriptionEventIndex = this.incomingEvents.findIndex((event: DynamoNTS_SocketEventParams<any>) => event.event === DynamoNTS_SocketEvent.subscribe);
75
79
  if (0 <= subscriptionEventIndex) {
76
80
  this.subscriptionEvent = this.incomingEvents.splice(subscriptionEventIndex)[0];
81
+ Dynamo_Log.error(
82
+ `You should not set the subscription event, but the subscriptions tasks, ` +
83
+ `in case you need additional steps for your subscripotions.`
84
+ );
77
85
  } else {
78
- this.subscriptionEvent = new DynamoNTS_SocketEventParams<SocketIO.Socket>({
79
- event: DynamoNTS_SocketEvent.subscribe,
80
- tasks: []
81
- });
86
+ this.subscriptionEvent = new DynamoNTS_SocketEventParams<SocketIO.Socket>({ event: DynamoNTS_SocketEvent.subscribe });
87
+ }
88
+ if (this.getSubscriptionPreProcessess) {
89
+ this.subscriptionEvent.preProcessess.push(...this.getSubscriptionPreProcessess());
90
+ }
91
+ if (this.getSubscriptionTasks) {
92
+ this.subscriptionEvent.tasks.push(...this.getSubscriptionTasks());
82
93
  }
83
94
 
84
95
  const disconnectEventIndex = this.incomingEvents.findIndex((event: DynamoNTS_SocketEventParams<any>) => event.event === DynamoNTS_SocketEvent.disconnect);
@@ -114,19 +125,32 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
114
125
  await this.connectEvent.tasks[i](socket);
115
126
  }
116
127
 
117
- if (this.getDicFromSubscrioption) {
128
+ if (this.getPresenceFromSubscrioptionEventContent) {
118
129
  socket.on(DynamoNTS_SocketEvent.subscribe, async (content: any) => {
119
- const dic: T = await this.getDicFromSubscrioption(content);
120
- issuer = dic.issuerId;
121
-
122
- this.socketSubscription(dic);
123
- this.subscriptionEvent.getFullExecution(issuer)(content);
130
+ try {
131
+ const presence: T_Presence = await this.getPresenceFromSubscrioptionEventContent(content);
132
+ issuer = presence.issuerId;
133
+
134
+ this.socketSubscription(presence);
135
+ await this.subscriptionEvent.executeEventTasks(issuer, content);
136
+ } catch (error) {
137
+ Dynamo_Log.error(`Socket Subscription failed: ${this.params.name} (${this.params.port})`, error);
138
+ socket.emit(DynamoNTS_SocketEvent.error, error);
139
+ }
124
140
  })
125
141
  }
126
142
 
127
143
  this.incomingEvents.forEach((event: DynamoNTS_SocketEventParams<any>) => {
128
- socket.on(event.event, event.getFullExecution(issuer));
144
+ socket.on(event.event, async (content: any) => {
145
+ try {
146
+ await event.executeEventTasks(issuer, content);
147
+ } catch (error) {
148
+ Dynamo_Log.error(`Socket Event failed: ${this.params.name} (${this.params.port})`, error);
149
+ socket.emit(DynamoNTS_SocketEvent.error, error);
150
+ }
151
+ });
129
152
  });
153
+
130
154
  });
131
155
 
132
156
  this.socketServer.listen(this.params.port);
@@ -137,22 +161,23 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
137
161
  );
138
162
  }
139
163
 
140
- private async socketSubscription(dictionary: T): Promise<void> {
141
- const activeSocket: T = this.activeSockets.find((dic: T) => dic.issuerId === dictionary.issuerId);
142
- if (activeSocket) {
143
- activeSocket.sockets.push(dictionary.sockets[0]);
164
+ protected async socketSubscription(newPresence: T_Presence): Promise<void> {
165
+ const activePresence: T_Presence = this.presences.find((pres: T_Presence) => pres.issuerId === newPresence.issuerId);
166
+ if (activePresence) {
167
+ activePresence.sockets.push(newPresence.sockets[0]);
144
168
  } else {
145
- this.activeSockets.push(dictionary);
169
+ this.presences.push(newPresence);
146
170
  }
147
171
  }
148
172
 
149
173
  private async removeSubscriptionOnDisconnect(socket: SocketIO.Socket): Promise<void> {
150
- const activeSocketIndex: number = this.activeSockets.findIndex((dic: DynamoNTS_SocketDictionary) => dic.sockets.includes(socket));
151
- if (0 <= activeSocketIndex) {
152
- const socketIndex = this.activeSockets[activeSocketIndex].sockets.findIndex((s: SocketIO.Socket) => s === socket);
153
- this.activeSockets[activeSocketIndex].sockets.splice(socketIndex);
154
- if (this.activeSockets[activeSocketIndex].sockets.length === 0) {
155
- this.activeSockets.splice(activeSocketIndex);
174
+ const activePresenceIndex: number = this.presences.findIndex((pres: DynamoNTS_SocketPresence) => pres.sockets.includes(socket));
175
+ if (0 <= activePresenceIndex) {
176
+ const presenceIndex = this.presences[activePresenceIndex].sockets.findIndex((s: SocketIO.Socket) => s === socket);
177
+ this.presences[activePresenceIndex].sockets.splice(presenceIndex);
178
+
179
+ if (this.presences[activePresenceIndex].sockets.length === 0) {
180
+ this.presences.splice(activePresenceIndex);
156
181
  }
157
182
  }
158
183
  }
@@ -162,13 +187,17 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
162
187
  }
163
188
 
164
189
  idIsSubscribed(id: string): boolean {
165
- return !!this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.issuerId === id);
190
+ return !!this.presences.find((presence: DynamoNTS_SocketPresence) => presence.issuerId === id);
191
+ }
192
+
193
+ emitError(presenceIssuerId: string, error: any): void {
194
+ this.sendEventForId(presenceIssuerId, DynamoNTS_SocketEvent.error, error);
166
195
  }
167
196
 
168
197
  async sendEventForId(id: string, event: string, content: any, error?: (err: any) => void): Promise<void> {
169
- const dic: DynamoNTS_SocketDictionary = this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.issuerId === id);
170
- if (dic) {
171
- dic.emitEvent(event, content);
198
+ const presence: DynamoNTS_SocketPresence = this.presences.find((pres: DynamoNTS_SocketPresence) => pres.issuerId === id);
199
+ if (presence) {
200
+ presence.emitEvent(event, content);
172
201
  } else {
173
202
  if (error) {
174
203
 
@@ -184,8 +213,8 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
184
213
  }
185
214
 
186
215
  broadcastEvent(event: string, content: any): void {
187
- this.activeSockets.forEach((dic: DynamoNTS_SocketDictionary) => {
188
- dic.emitEvent(event, content);
216
+ this.presences.forEach((presence: DynamoNTS_SocketPresence) => {
217
+ presence.emitEvent(event, content);
189
218
  })
190
219
  }
191
220
 
@@ -193,10 +222,20 @@ export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictiona
193
222
  * You must setup params for the service in this function
194
223
  *
195
224
  */
196
- abstract setupServiceParams(): void
225
+ abstract getServiceParams(): DynamoNTS_SocketServiceParams;
197
226
 
198
227
  /**
199
228
  * You must setup events and required services in this function
200
229
  */
201
- abstract setupEvents(): void
230
+ abstract getIncomingEvents(): DynamoNTS_SocketEventParams<any>[];
231
+
232
+ /**
233
+ * You can setup tasks for the subscription event in this function
234
+ */
235
+ protected getSubscriptionTasks?(): DynamoNTS_SocketEventTask[];
236
+
237
+ /**
238
+ * You can setup preprocessess for the subscription event in this function
239
+ */
240
+ protected getSubscriptionPreProcessess?(): DynamoNTS_SocketEventPreprocessTask<T_Content>[];
202
241
  }
@@ -3,8 +3,8 @@
3
3
 
4
4
  // SERVICES
5
5
  export * from './dynamo-nts-api.service';
6
- export * from './dynamo-nts-app';
7
- export * from './dynamo-nts-app-extended';
6
+ //export * from './dynamo-nts-app';
7
+ //export * from './dynamo-nts-app-extended';
8
8
  export * from './dynamo-nts-auth.service';
9
9
  export * from './dynamo-nts-controller.service';
10
10
  export * from './dynamo-nts-data.service';