@eleven-am/pondsocket 0.1.157 → 0.1.158

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.
@@ -297,34 +297,44 @@ class Channel {
297
297
  }
298
298
  broadcast(event, payload) {
299
299
  __classPrivateFieldGet(this, _Channel_engine, "f").sendMessage(pondsocket_common_1.SystemSender.CHANNEL, pondsocket_common_1.ChannelReceiver.ALL_USERS, pondsocket_common_1.ServerActions.BROADCAST, event, payload);
300
+ return this;
300
301
  }
301
302
  broadcastFrom(userId, event, payload) {
302
303
  __classPrivateFieldGet(this, _Channel_engine, "f").sendMessage(userId, pondsocket_common_1.ChannelReceiver.ALL_EXCEPT_SENDER, pondsocket_common_1.ServerActions.BROADCAST, event, payload);
304
+ return this;
303
305
  }
304
306
  broadcastTo(userIds, event, payload) {
305
307
  const users = Array.isArray(userIds) ? userIds : [userIds];
306
308
  __classPrivateFieldGet(this, _Channel_engine, "f").sendMessage(pondsocket_common_1.SystemSender.CHANNEL, users, pondsocket_common_1.ServerActions.BROADCAST, event, payload);
309
+ return this;
307
310
  }
308
311
  evictUser(userId, reason) {
309
312
  __classPrivateFieldGet(this, _Channel_engine, "f").kickUser(userId, reason !== null && reason !== void 0 ? reason : 'You have been banned from the channel');
313
+ return this;
310
314
  }
311
315
  trackPresence(userId, presence) {
312
316
  __classPrivateFieldGet(this, _Channel_engine, "f").presenceEngine.trackPresence(userId, presence);
317
+ return this;
313
318
  }
314
319
  removePresence(userId) {
315
320
  __classPrivateFieldGet(this, _Channel_engine, "f").presenceEngine.removePresence(userId);
321
+ return this;
316
322
  }
317
323
  updatePresence(userId, presence) {
318
324
  __classPrivateFieldGet(this, _Channel_engine, "f").presenceEngine.updatePresence(userId, presence);
325
+ return this;
319
326
  }
320
327
  updateAssigns(userId, assigns) {
321
328
  __classPrivateFieldGet(this, _Channel_engine, "f").updateAssigns(userId, assigns);
329
+ return this;
322
330
  }
323
331
  subscribeTo(userId, channel) {
324
332
  __classPrivateFieldGet(this, _Channel_engine, "f").subscribeTo(userId, channel);
333
+ return this;
325
334
  }
326
335
  unsubscribeFrom(userId, channel) {
327
336
  __classPrivateFieldGet(this, _Channel_engine, "f").unsubscribeFrom(userId, channel);
337
+ return this;
328
338
  }
329
339
  upsertPresence(userId, presence) {
330
340
  const oldPresence = __classPrivateFieldGet(this, _Channel_engine, "f").presenceEngine.getPresence()[userId];
@@ -334,6 +344,7 @@ class Channel {
334
344
  else {
335
345
  __classPrivateFieldGet(this, _Channel_engine, "f").presenceEngine.trackPresence(userId, presence);
336
346
  }
347
+ return this;
337
348
  }
338
349
  }
339
350
  exports.Channel = Channel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.157",
3
+ "version": "0.1.158",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
package/types.d.ts CHANGED
@@ -171,7 +171,7 @@ export declare class Channel<EventType extends PondEventMap = PondEventMap, Pres
171
171
  * @param {string} event - The event to send.
172
172
  * @param {PondMessage} payload - The message to send.
173
173
  */
174
- broadcast<Key extends keyof EventType>(event: Key, payload: EventType[Key]): void;
174
+ broadcast<Key extends keyof EventType>(event: Key, payload: EventType[Key]): Channel<EventType, PresenceType, AssignType>;
175
175
 
176
176
  /**
177
177
  * @desc Broadcasts a message to every client in the channel except the sender,
@@ -179,7 +179,7 @@ export declare class Channel<EventType extends PondEventMap = PondEventMap, Pres
179
179
  * @param {string} event - The event to send.
180
180
  * @param {PondMessage} payload - The message to send.
181
181
  */
182
- broadcastFrom<Key extends keyof EventType>(userId: string, event: Key, payload: EventType[Key]): void;
182
+ broadcastFrom<Key extends keyof EventType>(userId: string, event: Key, payload: EventType[Key]): Channel<EventType, PresenceType, AssignType>;
183
183
 
184
184
  /**
185
185
  * @desc Sends a message to a specific client in the channel.
@@ -187,62 +187,62 @@ export declare class Channel<EventType extends PondEventMap = PondEventMap, Pres
187
187
  * @param {string} event - The event to send.
188
188
  * @param {PondMessage} payload - The message to send.
189
189
  */
190
- broadcastTo<Key extends keyof EventType>(clientIds: string | string[], event: Key, payload: EventType[Key]): void;
190
+ broadcastTo<Key extends keyof EventType>(clientIds: string | string[], event: Key, payload: EventType[Key]): Channel<EventType, PresenceType, AssignType>;
191
191
 
192
192
  /**
193
193
  * @desc Bans a user from the channel.
194
194
  * @param {string} userId - The id of the user to ban.
195
195
  * @param {string} reason - The reason for the ban.
196
196
  */
197
- evictUser(userId: string, reason?: string): void;
197
+ evictUser(userId: string, reason?: string): Channel<EventType, PresenceType, AssignType>;
198
198
 
199
199
  /**
200
200
  * @desc tracks a user's presence in the channel
201
201
  * @param {string} userId - the id of the user to track
202
202
  * @param {PondPresence} presence - the presence data to track
203
203
  */
204
- trackPresence(userId: string, presence: PresenceType): void;
204
+ trackPresence(userId: string, presence: PresenceType): Channel<EventType, PresenceType, AssignType>;
205
205
 
206
206
  /**
207
207
  * @desc removes a user's presence from the channel
208
208
  * @param {string} userId - the id of the user to remove
209
209
  */
210
- removePresence(userId: string): void;
210
+ removePresence(userId: string): Channel<EventType, PresenceType, AssignType>;
211
211
 
212
212
  /**
213
213
  * @desc updates a user's presence in the channel
214
214
  * @param {string} userId - the id of the user to update
215
215
  * @param {PondPresence} presence - the presence data to update
216
216
  */
217
- updatePresence(userId: string, presence: PresenceType): void;
217
+ updatePresence(userId: string, presence: Partial<PresenceType>): Channel<EventType, PresenceType, AssignType>;
218
218
 
219
219
  /**
220
220
  * @desc Updates a user's assigns in the channel
221
221
  * @param userId - the id of the user to update
222
222
  * @param assigns - the assigns data to update
223
223
  */
224
- updateAssigns(userId: string, assigns: AssignType): void;
224
+ updateAssigns(userId: string, assigns: Partial<AssignType>): Channel<EventType, PresenceType, AssignType>;
225
225
 
226
226
  /**
227
227
  * @desc Tracks or updates a user's presence in the channel
228
228
  * @param userId - the id of the user to upsert
229
229
  * @param presence - the presence data to upsert
230
230
  */
231
- upsertPresence (userId: string, presence: PresenceType): void;
231
+ upsertPresence (userId: string, presence: PresenceType): Channel<EventType, PresenceType, AssignType>;
232
232
 
233
233
  /**
234
234
  * @desc Subscribes a user to a channel.
235
235
  * @param {string} userId - The id of the user.
236
236
  * @param {string} channel - The channel to subscribe to.
237
237
  */
238
- subscribeTo(userId: string, channel: string): void;
238
+ subscribeTo(userId: string, channel: string): Channel<EventType, PresenceType, AssignType>;
239
239
 
240
240
  /**
241
241
  * @desc Unsubscribes a user from a channel.
242
242
  * @param {string} userId - The id of the user.
243
243
  * @param {string} channel - The channel to unsubscribe from.
244
244
  */
245
- unsubscribeFrom(userId: string, channel: string): void;
245
+ unsubscribeFrom(userId: string, channel: string): Channel<EventType, PresenceType, AssignType>;
246
246
  }
247
247
 
248
248
  export declare class AbstractRequest<Path extends string, PresenceType extends PondPresence, AssignType extends PondAssigns> {