@trap_stevo/filetide 0.0.59 → 0.0.60

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.
@@ -264,8 +264,9 @@ class FileTide {
264
264
  * Stop a specific client.
265
265
  * @param {String} userID - The ID of the client user to stop
266
266
  * @param {Function} onDisconnect - Executes upon messager disconnection
267
+ * @param {Function} onCompletion - Executes upon messager disconnection completion
267
268
  */
268
- async stopMessager(userID, onDisconnect) {
269
+ async stopMessager(userID, onDisconnect, onCompletion) {
269
270
  if (this.clients.has(userID)) {
270
271
  FileTide.outputGradient(`Stopping messager for user ${userID}...`, significantMessageColors);
271
272
  const connectionOrigin = this.clients.get(userID);
@@ -278,11 +279,14 @@ class FileTide {
278
279
  FileTide.outputGradient(`Did not disconnect ~ ${userID} ~ ${error.message}`, errorMessageColors);
279
280
  }
280
281
  }
282
+ if (typeof onDisconnect === "function") {
283
+ await onDisconnect(this);
284
+ }
281
285
  }
282
286
  this.clients.delete(userID);
283
287
  FileTide.outputGradient(`Stopped messager for user ${userID}.`, significantMessageColors);
284
- if (typeof onDisconnect === "function") {
285
- await onDisconnect(this);
288
+ if (typeof onCompletion === "function") {
289
+ await onCompletion(this);
286
290
  }
287
291
  return;
288
292
  }
@@ -292,9 +296,10 @@ class FileTide {
292
296
 
293
297
  /**
294
298
  * Stop all active clients.
295
- * @param {Function} onDisconnect - Executes upon all messager disconnection
299
+ * @param {Function} onClientDisconnect - Executes upon each messager disconnection
300
+ * @param {Function} onCompletion - Executes upon all messager disconnection
296
301
  */
297
- async stopAllMessagers(onDisconnect) {
302
+ async stopAllMessagers(onClientDisconnect, onCompletion) {
298
303
  FileTide.outputGradient("Stopping all messagers...", significantMessageColors);
299
304
  const disconnectTasks = [];
300
305
  for (let [userID, connectionOrigin] of this.clients.entries()) {
@@ -305,6 +310,9 @@ class FileTide {
305
310
  if (result instanceof Promise) {
306
311
  await result;
307
312
  }
313
+ if (typeof onClientDisconnect === "function") {
314
+ onClientDisconnect(userID, connectionOrigin);
315
+ }
308
316
  FileTide.outputGradient(`Disconnected ~ ${userID}`, significantMessageColors);
309
317
  } catch (error) {
310
318
  FileTide.outputGradient(`Did not disconnect ~ ${userID} - ${error.message}`, errorMessageColors);
@@ -316,8 +324,8 @@ class FileTide {
316
324
  await Promise.all(disconnectTasks);
317
325
  this.clients.clear();
318
326
  FileTide.outputGradient("All messagers stopped.", significantMessageColors);
319
- if (typeof onDisconnect === "function") {
320
- await onDisconnect(this);
327
+ if (typeof onCompletion === "function") {
328
+ await onCompletion(this);
321
329
  }
322
330
  return;
323
331
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide",
3
- "version": "0.0.59",
3
+ "version": "0.0.60",
4
4
  "description": "Revolutionizing real-time file transfer with seamless, instant communication across any device. Deliver files instantly, regardless of platform, and experience unparalleled speed and control in managing transfers. Elevate your file-sharing capabilities with a tool designed for precision, efficiency, and effortless connectivity.",
5
5
  "main": "dist/cjs/FileTide.js",
6
6
  "scripts": {