@trap_stevo/filetide 0.0.60 → 0.0.61

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.
@@ -263,13 +263,17 @@ class FileTide {
263
263
  /**
264
264
  * Stop a specific client.
265
265
  * @param {String} userID - The ID of the client user to stop
266
+ * @param {Function} onBeforeDisconnect - Executes before messager disconnection
266
267
  * @param {Function} onDisconnect - Executes upon messager disconnection
267
268
  * @param {Function} onCompletion - Executes upon messager disconnection completion
268
269
  */
269
- async stopMessager(userID, onDisconnect, onCompletion) {
270
+ async stopMessager(userID, onBeforeDisconnect, onDisconnect, onCompletion) {
270
271
  if (this.clients.has(userID)) {
271
272
  FileTide.outputGradient(`Stopping messager for user ${userID}...`, significantMessageColors);
272
273
  const connectionOrigin = this.clients.get(userID);
274
+ if (typeof onBeforeDisconnect === "function") {
275
+ await onBeforeDisconnect(this, userID, connectionOrigin);
276
+ }
273
277
  if (connectionOrigin?.clientTide?.closeSocket) {
274
278
  const result = connectionOrigin.clientTide.closeSocket(userID);
275
279
  if (result instanceof Promise) {
@@ -280,13 +284,13 @@ class FileTide {
280
284
  }
281
285
  }
282
286
  if (typeof onDisconnect === "function") {
283
- await onDisconnect(this);
287
+ await onDisconnect(this, userID, connectionOrigin);
284
288
  }
285
289
  }
286
290
  this.clients.delete(userID);
287
291
  FileTide.outputGradient(`Stopped messager for user ${userID}.`, significantMessageColors);
288
292
  if (typeof onCompletion === "function") {
289
- await onCompletion(this);
293
+ await onCompletion(this, userID, connectionOrigin);
290
294
  }
291
295
  return;
292
296
  }
@@ -296,13 +300,17 @@ class FileTide {
296
300
 
297
301
  /**
298
302
  * Stop all active clients.
303
+ * @param {Function} onBeforeClientDisconnect - Executes before each messager disconnection
299
304
  * @param {Function} onClientDisconnect - Executes upon each messager disconnection
300
305
  * @param {Function} onCompletion - Executes upon all messager disconnection
301
306
  */
302
- async stopAllMessagers(onClientDisconnect, onCompletion) {
307
+ async stopAllMessagers(onBeforeClientDisconnect, onClientDisconnect, onCompletion) {
303
308
  FileTide.outputGradient("Stopping all messagers...", significantMessageColors);
304
309
  const disconnectTasks = [];
305
310
  for (let [userID, connectionOrigin] of this.clients.entries()) {
311
+ if (typeof onBeforeClientDisconnect === "function") {
312
+ await onBeforeClientDisconnect(this, userID, connectionOrigin);
313
+ }
306
314
  if (connectionOrigin?.clientTide?.closeSocket) {
307
315
  const task = async () => {
308
316
  try {
@@ -311,7 +319,7 @@ class FileTide {
311
319
  await result;
312
320
  }
313
321
  if (typeof onClientDisconnect === "function") {
314
- onClientDisconnect(userID, connectionOrigin);
322
+ await onClientDisconnect(this, userID, connectionOrigin);
315
323
  }
316
324
  FileTide.outputGradient(`Disconnected ~ ${userID}`, significantMessageColors);
317
325
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
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": {