@eleven-am/pondsocket 0.1.118 → 0.1.120
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/channel/channel.js +3 -0
- package/channel/eventResponse.js +11 -1
- package/nest.js +4 -9
- package/package.json +1 -1
- package/types.d.ts +10 -1
package/channel/channel.js
CHANGED
|
@@ -47,6 +47,9 @@ class Channel {
|
|
|
47
47
|
broadcastMessage(event, payload) {
|
|
48
48
|
__classPrivateFieldGet(this, _Channel_engine, "f").sendMessage(enums_1.SystemSender.CHANNEL, enums_1.ChannelReceiver.ALL_USERS, enums_1.ServerActions.BROADCAST, event, payload);
|
|
49
49
|
}
|
|
50
|
+
broadcastMessageFromUser(userId, event, payload) {
|
|
51
|
+
__classPrivateFieldGet(this, _Channel_engine, "f").sendMessage(userId, enums_1.ChannelReceiver.ALL_EXCEPT_SENDER, enums_1.ServerActions.BROADCAST, event, payload);
|
|
52
|
+
}
|
|
50
53
|
sendToUser(userId, event, payload) {
|
|
51
54
|
__classPrivateFieldGet(this, _Channel_engine, "f").sendMessage(enums_1.SystemSender.CHANNEL, [userId], enums_1.ServerActions.BROADCAST, event, payload);
|
|
52
55
|
}
|
package/channel/eventResponse.js
CHANGED
|
@@ -58,7 +58,7 @@ class EventResponse extends abstractResponse_1.PondResponse {
|
|
|
58
58
|
return this;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* @desc Emits a direct message to the client
|
|
61
|
+
* @desc Emits a direct message to the client, accepting the request
|
|
62
62
|
* @param event - the event name
|
|
63
63
|
* @param payload - the payload to send
|
|
64
64
|
* @param assigns - the data to assign to the client
|
|
@@ -67,6 +67,16 @@ class EventResponse extends abstractResponse_1.PondResponse {
|
|
|
67
67
|
this.accept(assigns);
|
|
68
68
|
__classPrivateFieldGet(this, _EventResponse_engine, "f").sendMessage(enums_1.SystemSender.CHANNEL, [__classPrivateFieldGet(this, _EventResponse_event, "f").sender], enums_1.ServerActions.SYSTEM, event, payload);
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* @desc Emits a direct message to the client without accepting the request
|
|
72
|
+
* @param event - the event name
|
|
73
|
+
* @param payload - the payload to send
|
|
74
|
+
* @param assigns - the data to assign to the client
|
|
75
|
+
*/
|
|
76
|
+
sendOnly(event, payload, assigns) {
|
|
77
|
+
__classPrivateFieldGet(this, _EventResponse_instances, "m", _EventResponse_manageAssigns).call(this, assigns);
|
|
78
|
+
__classPrivateFieldGet(this, _EventResponse_engine, "f").sendMessage(enums_1.SystemSender.CHANNEL, [__classPrivateFieldGet(this, _EventResponse_event, "f").sender], enums_1.ServerActions.SYSTEM, event, payload);
|
|
79
|
+
}
|
|
70
80
|
/**
|
|
71
81
|
* @desc Sends a message to all clients in the channel
|
|
72
82
|
* @param event - the event to send
|
package/nest.js
CHANGED
|
@@ -263,15 +263,15 @@ class Context {
|
|
|
263
263
|
return (_a = this.data[key]) !== null && _a !== void 0 ? _a : null;
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
function manageResponse(data, channel,
|
|
266
|
+
function manageResponse(data, channel, response) {
|
|
267
267
|
if (response && response.hasResponded || !isNotEmpty(data)) {
|
|
268
268
|
return;
|
|
269
269
|
}
|
|
270
270
|
const { event, presence, updatePresence, assigns, broadcast } = data, rest = __rest(data, ["event", "presence", "updatePresence", "assigns", "broadcast"]);
|
|
271
271
|
if (response) {
|
|
272
272
|
if (event && typeof event === 'string' && isNotEmpty(rest)) {
|
|
273
|
-
if (
|
|
274
|
-
response.
|
|
273
|
+
if (response instanceof eventResponse_1.EventResponse) {
|
|
274
|
+
response.sendOnly(event, rest, assigns);
|
|
275
275
|
}
|
|
276
276
|
else {
|
|
277
277
|
response.send(event, rest, assigns);
|
|
@@ -542,28 +542,23 @@ function manageAction(instance, moduleRef, originalMethod, propertyKey, leaveEve
|
|
|
542
542
|
const req = {};
|
|
543
543
|
const res = {};
|
|
544
544
|
let channel = null;
|
|
545
|
-
let clientId = null;
|
|
546
545
|
if (request && response) {
|
|
547
546
|
if (request instanceof joinRequest_1.JoinRequest && response instanceof joinResponse_1.JoinResponse) {
|
|
548
547
|
channel = request.channel;
|
|
549
|
-
clientId = request.user.id;
|
|
550
548
|
req.joinRequest = request;
|
|
551
549
|
res.joinResponse = response;
|
|
552
550
|
}
|
|
553
551
|
else if (request instanceof eventRequest_1.EventRequest && response instanceof eventResponse_1.EventResponse) {
|
|
554
552
|
channel = request.channel;
|
|
555
|
-
clientId = request.user.id;
|
|
556
553
|
req.eventRequest = request;
|
|
557
554
|
res.eventResponse = response;
|
|
558
555
|
}
|
|
559
556
|
else if ('headers' in request && response instanceof response_1.ConnectionResponse) {
|
|
560
|
-
clientId = request.id;
|
|
561
557
|
req.connection = request;
|
|
562
558
|
res.connection = response;
|
|
563
559
|
}
|
|
564
560
|
}
|
|
565
561
|
else if (leaveEvent) {
|
|
566
|
-
clientId = leaveEvent.userId;
|
|
567
562
|
channel = leaveEvent.channel;
|
|
568
563
|
req.leveeEvent = leaveEvent;
|
|
569
564
|
}
|
|
@@ -571,7 +566,7 @@ function manageAction(instance, moduleRef, originalMethod, propertyKey, leaveEve
|
|
|
571
566
|
const canProceed = yield resolveGuards(moduleRef, context);
|
|
572
567
|
if (canProceed) {
|
|
573
568
|
const data = yield originalMethod.apply(instance, resolveParameters(context));
|
|
574
|
-
manageResponse(data, channel,
|
|
569
|
+
manageResponse(data, channel, response);
|
|
575
570
|
}
|
|
576
571
|
else if (response) {
|
|
577
572
|
response.reject('Unauthorized', 401);
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -266,13 +266,22 @@ declare class EventResponse extends PondResponse {
|
|
|
266
266
|
reject (message?: string, errorCode?: number, assigns?: PondAssigns): EventResponse;
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
|
-
* @desc Emits a direct message to the client
|
|
269
|
+
* @desc Emits a direct message to the client, accepting the request
|
|
270
270
|
* @param event - the event name
|
|
271
271
|
* @param payload - the payload to send
|
|
272
272
|
* @param assigns - the data to assign to the client
|
|
273
273
|
*/
|
|
274
274
|
send (event: string, payload: PondMessage, assigns?: PondAssigns): void;
|
|
275
275
|
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @desc Emits a direct message to the client without accepting the request
|
|
279
|
+
* @param event - the event name
|
|
280
|
+
* @param payload - the payload to send
|
|
281
|
+
* @param assigns - the data to assign to the client
|
|
282
|
+
*/
|
|
283
|
+
sendOnly (event: string, payload: PondMessage, assigns?: PondAssigns): void;
|
|
284
|
+
|
|
276
285
|
/**
|
|
277
286
|
* @desc Sends a message to all clients in the channel
|
|
278
287
|
* @param event - the event to send
|