@futdevpro/nts-dynamo 1.5.40 → 1.5.47
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.
- package/futdevpro-nts-dynamo-01.05.41.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.42.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.43.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.44.tgz +0 -0
- package/futdevpro-nts-dynamo-01.05.45.tgz +0 -0
- package/lib/_enums/http/socket-event.enum.d.ts +2 -0
- package/lib/_enums/http/socket-event.enum.d.ts.map +1 -1
- package/lib/_enums/http/socket-event.enum.js +2 -0
- package/lib/_enums/http/socket-event.enum.js.map +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.js +1 -1
- package/lib/_models/dynamo-nts-endpoint-params.js.map +1 -1
- package/lib/_models/dynamo-nts-socket-dictionary.d.ts +16 -0
- package/lib/_models/dynamo-nts-socket-dictionary.d.ts.map +1 -0
- package/lib/_models/dynamo-nts-socket-dictionary.js +31 -0
- package/lib/_models/dynamo-nts-socket-dictionary.js.map +1 -0
- package/lib/_models/dynamo-nts-socket-event-params.d.ts +2 -0
- package/lib/_models/dynamo-nts-socket-event-params.d.ts.map +1 -1
- package/lib/_models/dynamo-nts-socket-event-params.js +6 -5
- package/lib/_models/dynamo-nts-socket-event-params.js.map +1 -1
- package/lib/_models/index.d.ts +1 -0
- package/lib/_models/index.d.ts.map +1 -1
- package/lib/_models/index.js +1 -0
- package/lib/_models/index.js.map +1 -1
- package/lib/_modules/app-extended.index.d.ts +1 -0
- package/lib/_modules/app-extended.index.d.ts.map +1 -1
- package/lib/_modules/app-extended.index.js +1 -0
- package/lib/_modules/app-extended.index.js.map +1 -1
- package/lib/_modules/test/custom-data.service.d.ts +3 -3
- package/lib/_modules/test/custom-data.service.d.ts.map +1 -1
- package/lib/_modules/test/custom-data.service.js +4 -4
- package/lib/_modules/test/custom-data.service.js.map +1 -1
- package/lib/_modules/test/test-controller.js +6 -6
- package/lib/_modules/test/test-controller.js.map +1 -1
- package/lib/_modules/usage/usage-controller.js +1 -1
- package/lib/_modules/usage/usage-controller.js.map +1 -1
- package/lib/_modules/usage/usage.service.d.ts +6 -6
- package/lib/_modules/usage/usage.service.d.ts.map +1 -1
- package/lib/_modules/usage/usage.service.js +18 -10
- package/lib/_modules/usage/usage.service.js.map +1 -1
- package/lib/_services/dynamo-nts-api.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-api.service.js +19 -8
- package/lib/_services/dynamo-nts-api.service.js.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.d.ts +1 -1
- package/lib/_services/dynamo-nts-app-extended.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app-extended.js +2 -4
- package/lib/_services/dynamo-nts-app-extended.js.map +1 -1
- package/lib/_services/dynamo-nts-app.d.ts +1 -0
- package/lib/_services/dynamo-nts-app.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-app.js +4 -1
- package/lib/_services/dynamo-nts-app.js.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-auth.service.js +10 -4
- package/lib/_services/dynamo-nts-auth.service.js.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.d.ts +37 -0
- package/lib/_services/dynamo-nts-controller.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-controller.service.js +37 -0
- package/lib/_services/dynamo-nts-controller.service.js.map +1 -1
- package/lib/_services/dynamo-nts-data.service.d.ts +21 -2
- package/lib/_services/dynamo-nts-data.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-data.service.js +121 -53
- package/lib/_services/dynamo-nts-data.service.js.map +1 -1
- package/lib/_services/dynamo-nts-db.service.d.ts +4 -4
- package/lib/_services/dynamo-nts-db.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-db.service.js +148 -84
- package/lib/_services/dynamo-nts-db.service.js.map +1 -1
- package/lib/_services/dynamo-nts-email.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-email.service.js +20 -16
- package/lib/_services/dynamo-nts-email.service.js.map +1 -1
- package/lib/_services/dynamo-nts-global.service.d.ts +5 -5
- package/lib/_services/dynamo-nts-global.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-global.service.js.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-routing-module.service.js +17 -11
- package/lib/_services/dynamo-nts-routing-module.service.js.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.d.ts +6 -0
- package/lib/_services/dynamo-nts-shared.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-shared.service.js +8 -0
- package/lib/_services/dynamo-nts-shared.service.js.map +1 -1
- package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts +1 -1
- package/lib/_services/dynamo-nts-socket-service-collection.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.d.ts +6 -9
- package/lib/_services/dynamo-nts-socket.service.d.ts.map +1 -1
- package/lib/_services/dynamo-nts-socket.service.js +25 -20
- package/lib/_services/dynamo-nts-socket.service.js.map +1 -1
- package/lib/_services/dynamobe-api.service.js +2 -2
- package/lib/_services/dynamobe-auth.service.js +2 -2
- package/lib/_services/dynamobe-data.service.d.ts +2 -2
- package/lib/_services/dynamobe-data.service.js +15 -15
- package/lib/_services/dynamobe-db.service.d.ts +4 -4
- package/lib/_services/dynamobe-db.service.js +28 -28
- package/lib/_services/dynamobe-email.service.js +4 -4
- package/lib/_services/dynamobe-global.service.d.ts +3 -3
- package/lib/_services/dynamobe-routing-module.service.js +3 -3
- package/lib/tsconfig.tsbuildinfo +1 -5564
- package/package.json +22 -12
- package/src/_enums/http/socket-event.enum.ts +2 -0
- package/src/_models/dynamo-nts-endpoint-params.ts +1 -1
- package/src/_models/dynamo-nts-socket-dictionary.ts +39 -0
- package/src/_models/dynamo-nts-socket-event-params.ts +8 -5
- package/src/_models/index.ts +1 -0
- package/src/_modules/app-extended.index.ts +1 -0
- package/src/_modules/test/custom-data.service.ts +4 -4
- package/src/_modules/test/test-controller.ts +7 -7
- package/src/_modules/usage/usage-controller.ts +2 -2
- package/src/_modules/usage/usage.service.ts +34 -26
- package/src/_services/dynamo-nts-api.service.ts +26 -9
- package/src/_services/dynamo-nts-app-extended.ts +9 -9
- package/src/_services/dynamo-nts-app.ts +2 -2
- package/src/_services/dynamo-nts-auth.service.ts +13 -5
- package/src/_services/dynamo-nts-controller.service.ts +37 -0
- package/src/_services/dynamo-nts-data.service.ts +123 -55
- package/src/_services/dynamo-nts-db.service.ts +181 -87
- package/src/_services/dynamo-nts-email.service.ts +21 -17
- package/src/_services/dynamo-nts-global.service.ts +12 -5
- package/src/_services/dynamo-nts-routing-module.service.ts +16 -10
- package/src/_services/dynamo-nts-shared.service.ts +9 -0
- package/src/_services/dynamo-nts-socket-service-collection.service.ts +1 -1
- package/src/_services/dynamo-nts-socket.service.ts +33 -29
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { Dynamo_Metadata, DynamoNTS_DataParams } from '@futdevpro/fsm-dynamo';
|
|
4
4
|
|
|
5
5
|
import { DynamoNTS_AuthService } from './dynamo-nts-auth.service';
|
|
6
6
|
import { DynamoNTS_DBServiceCollection } from './dynamo-nts-db-service-collection.service';
|
|
@@ -79,6 +79,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
79
79
|
`\nPlease create a Unique Authentication Service extending DynamoNTS_AuthService, ` +
|
|
80
80
|
`and Setup with "DBE_Global_SC.setServices(...)"`);
|
|
81
81
|
}
|
|
82
|
+
|
|
82
83
|
return this.instance.authService;
|
|
83
84
|
}
|
|
84
85
|
|
|
@@ -93,6 +94,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
93
94
|
`\nPlease create a Unique DataBase Service Collection extending DynamoNTS_DBServiceCollection, ` +
|
|
94
95
|
`and Setup with "DBE_Global_SC.setServices(...)"`);
|
|
95
96
|
}
|
|
97
|
+
|
|
96
98
|
return this.instance.dbServiceCollection;
|
|
97
99
|
}
|
|
98
100
|
|
|
@@ -101,7 +103,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
101
103
|
* @param dataParams
|
|
102
104
|
* @returns
|
|
103
105
|
*/
|
|
104
|
-
static getDBService<T extends
|
|
106
|
+
static getDBService<T extends Dynamo_Metadata>(dataParams: DynamoNTS_DataParams): DynamoNTS_DBService<T> {
|
|
105
107
|
return this.getDBServiceByKey<T>(dataParams.dataName);
|
|
106
108
|
}
|
|
107
109
|
|
|
@@ -110,13 +112,14 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
110
112
|
* @param key
|
|
111
113
|
* @returns
|
|
112
114
|
*/
|
|
113
|
-
static getDBServiceByKey<T extends
|
|
115
|
+
static getDBServiceByKey<T extends Dynamo_Metadata>(key: string): DynamoNTS_DBService<T> {
|
|
114
116
|
const collection = this.getDBServiceCollection();
|
|
115
117
|
if (collection[key]) {
|
|
116
118
|
return collection[key] as DynamoNTS_DBService<T>;
|
|
117
119
|
} else {
|
|
118
120
|
let keys: string = `${Object.keys(collection)}`;
|
|
119
121
|
keys = keys.replace(/,/g, '\n ');
|
|
122
|
+
|
|
120
123
|
throw new Error(
|
|
121
124
|
`\nDBE_Global_S.getDBService failed, ERROR:
|
|
122
125
|
no dbService on collection with this key: ${key}!
|
|
@@ -136,6 +139,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
136
139
|
`\nPlease create a Unique Email Service Collection extending DynamoBEEmailServiceCollection, ` +
|
|
137
140
|
`and Setup with "DBE_Global_SC.setServices(...)"`);
|
|
138
141
|
}
|
|
142
|
+
|
|
139
143
|
return this.instance.emailServiceCollection;
|
|
140
144
|
}
|
|
141
145
|
|
|
@@ -151,6 +155,7 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
151
155
|
`in the setupModules in the App using DynamoNTS_AppExtended, ` +
|
|
152
156
|
`and Setup with "DBE_Global_SC.setServices(...)"`);
|
|
153
157
|
}
|
|
158
|
+
|
|
154
159
|
return this.instance.socketServiceCollection;
|
|
155
160
|
}
|
|
156
161
|
|
|
@@ -159,13 +164,14 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
159
164
|
* @param name
|
|
160
165
|
* @returns
|
|
161
166
|
*/
|
|
162
|
-
static getSocketServiceByName(name: string): DynamoNTS_SocketService {
|
|
167
|
+
static getSocketServiceByName(name: string): DynamoNTS_SocketService<any> {
|
|
163
168
|
const collection = this.getSocketServiceCollection();
|
|
164
169
|
if (collection[name]) {
|
|
165
170
|
return collection[name];
|
|
166
171
|
} else {
|
|
167
172
|
let names: string = `${Object.keys(collection)}`;
|
|
168
173
|
names = names.replace(/,/g, '\n ');
|
|
174
|
+
|
|
169
175
|
throw new Error(
|
|
170
176
|
`\nDBE_Global_S.getSocketServiceByName failed, ERROR:
|
|
171
177
|
no socketService on collection with this name: ${name}!
|
|
@@ -174,13 +180,14 @@ export class DynamoNTS_GlobalService extends DynamoNTS_SingletonService {
|
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
182
|
|
|
177
|
-
static attachNewSocketService(service: DynamoNTS_SocketService): void {
|
|
183
|
+
static attachNewSocketService(service: DynamoNTS_SocketService<any>): void {
|
|
178
184
|
const collection = this.getSocketServiceCollection();
|
|
179
185
|
if (!collection[service.name]) {
|
|
180
186
|
collection[service.name] = service;
|
|
181
187
|
} else {
|
|
182
188
|
let names: string = `${Object.keys(collection)}`;
|
|
183
189
|
names = names.replace(/,/g, '\n ');
|
|
190
|
+
|
|
184
191
|
throw new Error(
|
|
185
192
|
`\nDBE_Global_S.attachNewSocketService failed, ERROR:
|
|
186
193
|
socketService name is already taken on collection with this name: ${service.name}!
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { Router } from 'express';
|
|
3
|
-
import {
|
|
3
|
+
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
4
4
|
|
|
5
5
|
import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
|
|
6
6
|
import { DynamoNTS_RouteSecurity } from '../_enums/dynamo-nts-route-security.enum';
|
|
@@ -89,9 +89,11 @@ export class DynamoNTS_RoutingModule {
|
|
|
89
89
|
this.mountSecureRoute(endpoint);
|
|
90
90
|
}
|
|
91
91
|
} catch (error) {
|
|
92
|
-
throw new
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
throw new Dynamo_Error({
|
|
93
|
+
errorCode: 'NTS-RM9-100',
|
|
94
|
+
addECToUserMsg: true,
|
|
95
|
+
message: `DYNAMO-NTS ERROR: Failed to mount routes.`,
|
|
96
|
+
userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team.`,
|
|
95
97
|
error
|
|
96
98
|
})
|
|
97
99
|
}
|
|
@@ -125,9 +127,11 @@ export class DynamoNTS_RoutingModule {
|
|
|
125
127
|
endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
126
128
|
break;
|
|
127
129
|
default:
|
|
128
|
-
throw new
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
throw new Dynamo_Error({
|
|
131
|
+
errorCode: 'NTS-RM9-200',
|
|
132
|
+
addECToUserMsg: true,
|
|
133
|
+
message: `DYNAMO-NTS ERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}` ,
|
|
134
|
+
userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team.`,
|
|
131
135
|
error: new Error()
|
|
132
136
|
})
|
|
133
137
|
}
|
|
@@ -160,9 +164,11 @@ export class DynamoNTS_RoutingModule {
|
|
|
160
164
|
endpointParams.preProcessess, endpointParams.getTasksExecution());
|
|
161
165
|
break;
|
|
162
166
|
default:
|
|
163
|
-
throw new
|
|
164
|
-
|
|
165
|
-
|
|
167
|
+
throw new Dynamo_Error({
|
|
168
|
+
errorCode: 'NTS-RM9-300',
|
|
169
|
+
addECToUserMsg: true,
|
|
170
|
+
message: `DYNAMO-NTS ERROR: INVALID route type: ${endpointParams.type} - ${endpointParams.name}`,
|
|
171
|
+
userMessage: `We encountered an uncought BackEnd Build Error, please contact the responsible development team.`,
|
|
166
172
|
error: new Error()
|
|
167
173
|
})
|
|
168
174
|
}
|
|
@@ -35,6 +35,15 @@ export class DynamoNTS_Shared extends Dynamo_Shared {
|
|
|
35
35
|
return GeoIp.lookup(this.getIpFromRequest(request));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param request
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
static getLocationByIp(ip: string): GeoIpLocation {
|
|
44
|
+
return GeoIp.lookup(ip);
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
/**
|
|
39
48
|
*
|
|
40
49
|
* @param question
|
|
@@ -11,6 +11,6 @@ export class DynamoNTS_SocketServiceCollection extends DynamoNTS_SingletonServic
|
|
|
11
11
|
return DynamoNTS_SocketServiceCollection.getSingletonInstance();
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
[service: string]: DynamoNTS_SocketService
|
|
14
|
+
[service: string]: DynamoNTS_SocketService<any>;
|
|
15
15
|
|
|
16
16
|
}
|
|
@@ -3,23 +3,19 @@ import * as SocketIO from 'socket.io';
|
|
|
3
3
|
|
|
4
4
|
import { dynamoNTS_GlobalSettings } from '../_constants/dynamo-nts-global-settings';
|
|
5
5
|
import { DynamoNTS_Shared } from './dynamo-nts-shared.service';
|
|
6
|
-
import { DynamoNTS_SocketServiceParams } from '../_models';
|
|
7
6
|
import { DynamoNTS_SingletonService } from './dynamo-nts-singleton.service';
|
|
8
7
|
import { DynamoNTS_SocketEventParams } from '../_models/dynamo-nts-socket-event-params';
|
|
9
8
|
import { DynamoNTS_SocketEvent } from '../_enums/http/socket-event.enum';
|
|
10
9
|
import { DynamoNTS_GlobalService } from './dynamo-nts-global.service';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
id?: string;
|
|
16
|
-
sockets: SocketIO.Socket[];
|
|
17
|
-
}
|
|
10
|
+
import { Dynamo_Error } from '@futdevpro/fsm-dynamo';
|
|
11
|
+
import { DynamoNTS_SocketServiceParams } from '../_models/dynamo-nts-socket-service-params';
|
|
12
|
+
import { DynamoNTS_SocketDictionary } from '../_models/dynamo-nts-socket-dictionary';
|
|
13
|
+
import { DynamoNTS_SocketSecurity } from '../_enums/dynamo-nts-socket-security.enum';
|
|
18
14
|
|
|
19
15
|
/**
|
|
20
16
|
*
|
|
21
17
|
*/
|
|
22
|
-
export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService {
|
|
18
|
+
export abstract class DynamoNTS_SocketService<T extends DynamoNTS_SocketDictionary> extends DynamoNTS_SingletonService {
|
|
23
19
|
protected params: DynamoNTS_SocketServiceParams;
|
|
24
20
|
get name(): string { return this.params.name; }
|
|
25
21
|
get port(): number { return this.params.port; }
|
|
@@ -31,8 +27,8 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
|
|
|
31
27
|
protected incomingEvents: DynamoNTS_SocketEventParams<any>[];
|
|
32
28
|
|
|
33
29
|
private subscriptionEvent: DynamoNTS_SocketEventParams<any>;
|
|
34
|
-
private
|
|
35
|
-
|
|
30
|
+
private getDicFromSubscrioption?: (content: any) => Promise<T>;
|
|
31
|
+
protected activeSockets: T[] = [];
|
|
36
32
|
|
|
37
33
|
protected log: boolean = dynamoNTS_GlobalSettings.logSetup;
|
|
38
34
|
|
|
@@ -69,8 +65,9 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
|
|
|
69
65
|
tasks: []
|
|
70
66
|
});
|
|
71
67
|
}
|
|
68
|
+
this.connectEvent.socketName = this.params.name;
|
|
72
69
|
|
|
73
|
-
if (this.
|
|
70
|
+
if (this.getDicFromSubscrioption) {
|
|
74
71
|
const subscriptionEventIndex = this.incomingEvents.findIndex((event: DynamoNTS_SocketEventParams<any>) => event.event === DynamoNTS_SocketEvent.subscribe);
|
|
75
72
|
if (0 <= subscriptionEventIndex) {
|
|
76
73
|
this.subscriptionEvent = this.incomingEvents.splice(subscriptionEventIndex)[0];
|
|
@@ -92,7 +89,13 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
|
|
|
92
89
|
]
|
|
93
90
|
}));
|
|
94
91
|
}
|
|
92
|
+
|
|
93
|
+
this.subscriptionEvent.socketName = this.params.name;
|
|
95
94
|
}
|
|
95
|
+
|
|
96
|
+
this.incomingEvents.forEach((event: DynamoNTS_SocketEventParams<any>) => {
|
|
97
|
+
event.socketName = this.params.name;
|
|
98
|
+
});
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
async setupSocketServer(newSocketServer: SocketIO.Server): Promise<void> {
|
|
@@ -108,11 +111,12 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
|
|
|
108
111
|
await this.connectEvent.tasks[i](socket);
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
if (this.
|
|
114
|
+
if (this.getDicFromSubscrioption) {
|
|
112
115
|
socket.on(DynamoNTS_SocketEvent.subscribe, async (content: any) => {
|
|
113
|
-
|
|
116
|
+
const dic: T = await this.getDicFromSubscrioption(content);
|
|
117
|
+
issuer = dic.issuerId;
|
|
114
118
|
|
|
115
|
-
this.socketSubscription(
|
|
119
|
+
this.socketSubscription(dic);
|
|
116
120
|
this.subscriptionEvent.getFullExecution(issuer)(content);
|
|
117
121
|
})
|
|
118
122
|
}
|
|
@@ -124,18 +128,18 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
|
|
|
124
128
|
|
|
125
129
|
this.socketServer.listen(this.params.port);
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
console.log(
|
|
128
132
|
`\nsocket service setup finished: ${this.params.name}` +
|
|
129
133
|
`\nsocket server listening on port: ${this.params.port}`
|
|
130
134
|
);
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
private async socketSubscription(
|
|
134
|
-
const activeSocket:
|
|
137
|
+
private async socketSubscription(dictionary: T): Promise<void> {
|
|
138
|
+
const activeSocket: T = this.activeSockets.find((dic: T) => dic.issuerId === dictionary.issuerId);
|
|
135
139
|
if (activeSocket) {
|
|
136
|
-
activeSocket.sockets.push(
|
|
140
|
+
activeSocket.sockets.push(dictionary.sockets[0]);
|
|
137
141
|
} else {
|
|
138
|
-
this.activeSockets.push(
|
|
142
|
+
this.activeSockets.push(dictionary);
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
|
|
@@ -155,26 +159,26 @@ export abstract class DynamoNTS_SocketService extends DynamoNTS_SingletonService
|
|
|
155
159
|
}
|
|
156
160
|
|
|
157
161
|
idIsSubscribed(id: string): boolean {
|
|
158
|
-
return !!this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.
|
|
162
|
+
return !!this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.issuerId === id);
|
|
159
163
|
}
|
|
160
164
|
|
|
161
165
|
async sendEventForId(id: string, event: string, content: any, error?: (err: any) => void): Promise<void> {
|
|
162
|
-
const dic: DynamoNTS_SocketDictionary = this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.
|
|
166
|
+
const dic: DynamoNTS_SocketDictionary = this.activeSockets.find((dic: DynamoNTS_SocketDictionary) => dic.issuerId === id);
|
|
163
167
|
if (dic) {
|
|
164
|
-
dic.
|
|
165
|
-
socket.emit(event, content);
|
|
166
|
-
});
|
|
168
|
+
dic.emitEvent(event, content);
|
|
167
169
|
} else {
|
|
168
170
|
if (error)
|
|
169
|
-
throw new
|
|
171
|
+
throw new Dynamo_Error({
|
|
172
|
+
status: 404,
|
|
173
|
+
errorCode: 'NTS-S99-001',
|
|
174
|
+
message: `No active socket whit this specific ID: ${id}`
|
|
175
|
+
});
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
178
|
|
|
173
179
|
broadcastEvent(event: string, content: any): void {
|
|
174
180
|
this.activeSockets.forEach((dic: DynamoNTS_SocketDictionary) => {
|
|
175
|
-
dic.
|
|
176
|
-
socket.emit(event, content);
|
|
177
|
-
})
|
|
181
|
+
dic.emitEvent(event, content);
|
|
178
182
|
})
|
|
179
183
|
}
|
|
180
184
|
|