@eleven-am/pondsocket 0.1.151 → 0.1.152
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 +9 -0
- package/package.json +1 -1
- package/types.d.ts +7 -0
package/channel/channel.js
CHANGED
|
@@ -323,6 +323,15 @@ class Channel {
|
|
|
323
323
|
unsubscribeFrom(userId, channel) {
|
|
324
324
|
__classPrivateFieldGet(this, _Channel_engine, "f").unsubscribeFrom(userId, channel);
|
|
325
325
|
}
|
|
326
|
+
upsertPresence(userId, presence) {
|
|
327
|
+
const oldPresence = __classPrivateFieldGet(this, _Channel_engine, "f").presenceEngine.getPresence()[userId];
|
|
328
|
+
if (oldPresence) {
|
|
329
|
+
__classPrivateFieldGet(this, _Channel_engine, "f").presenceEngine.updatePresence(userId, presence);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
__classPrivateFieldGet(this, _Channel_engine, "f").presenceEngine.trackPresence(userId, presence);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
326
335
|
}
|
|
327
336
|
exports.Channel = Channel;
|
|
328
337
|
_Channel_engine = new WeakMap();
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -216,6 +216,13 @@ export declare class Channel<EventType extends PondEventMap = PondEventMap, Pres
|
|
|
216
216
|
*/
|
|
217
217
|
updatePresence(userId: string, presence: PresenceType): void;
|
|
218
218
|
|
|
219
|
+
/**
|
|
220
|
+
* @desc Tracks or updates a user's presence in the channel
|
|
221
|
+
* @param userId - the id of the user to upsert
|
|
222
|
+
* @param presence - the presence data to upsert
|
|
223
|
+
*/
|
|
224
|
+
upsertPresence (userId: string, presence: PresenceType): void;
|
|
225
|
+
|
|
219
226
|
/**
|
|
220
227
|
* @desc Subscribes a user to a channel.
|
|
221
228
|
* @param {string} userId - The id of the user.
|