@eleven-am/pondsocket 0.1.150 → 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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.150",
3
+ "version": "0.1.152",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
package/types.d.ts CHANGED
@@ -164,7 +164,7 @@ export declare class Channel<EventType extends PondEventMap = PondEventMap, Pres
164
164
  * @desc Gets the assign date for a specific user.
165
165
  * @param {string} userId - The id of the user to get the data for.
166
166
  */
167
- getUserData(userId: string): AssignType | null;
167
+ getUserData(userId: string): UserData<PresenceType, AssignType> | null;
168
168
 
169
169
  /**
170
170
  * @desc Broadcasts a message to every client in the channel,
@@ -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.