@trap_stevo/filetide 0.0.3 → 0.0.4

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.
@@ -31,6 +31,7 @@ class FileMessager {
31
31
  this.fileNet.on("transfer-complete", this.handleFileTransferComplete.bind(this));
32
32
  this.fileNet.on("client-to-client-transfer", this.handleClientToClientTransfer.bind(this));
33
33
  this.fileNet.on("client-offline", this.handleClientOffline.bind(this));
34
+ this.fileNet.on("clients-online", this.handleClientsOnline.bind(this));
34
35
  this.fileNet.on("client-online", this.handleClientOnline.bind(this));
35
36
  return;
36
37
  }
@@ -57,7 +58,12 @@ class FileMessager {
57
58
  fileData,
58
59
  path: filePath
59
60
  });
60
- console.log(`File ${fileName} sent to client ${clientId}!`);
61
+ console.log(`[FileTide ~ File Messager] ~ File ${fileName} sent to client ${clientId}!`);
62
+ client.emit("transfer-status", {
63
+ status: `[FileTide ~ File Messager] ~ File ${fileName} sent to client ${clientId}!`,
64
+ receivingClientID: clientId,
65
+ success: true
66
+ });
61
67
  return;
62
68
  }
63
69
 
@@ -75,6 +81,12 @@ class FileMessager {
75
81
  this.sendFileToClient(recipientId, fileData, fileName, filePath);
76
82
  return;
77
83
  }
84
+ handleClientsOnline() {
85
+ this.fileNet.emit("clients-online", {
86
+ currentClients: this.messagerClients
87
+ });
88
+ return;
89
+ }
78
90
  handleClientOnline(clientID, connectionID) {
79
91
  if (!this.onlineClients.has(connectionID)) {
80
92
  return;
@@ -19,7 +19,7 @@ class FileMessagerClient {
19
19
  this.clientTide.createIO(clientID, clientOptions.url, {
20
20
  transports: ["websocket"]
21
21
  });
22
- console.log(`[FileTide ~ File Messager] ~ Created client with ID ${clientID} and socket ${clientID}`);
22
+ console.log(`[FileTide ~ File Messager] ~ Created client with ID ${clientID} and socket ${clientID}!`);
23
23
  return clientID;
24
24
  }
25
25
  joinRoom(userID, roomName) {
@@ -27,20 +27,20 @@ class FileMessagerClient {
27
27
  url: this.clientOptions.url
28
28
  });
29
29
  this.clientTide.joinChannel(socketName, roomName, userID, () => {
30
- console.log(`[FileTide ~ File Messager] ~ Client ~ ${userID} joined room ${roomName} successfully.`);
30
+ console.log(`[FileTide ~ File Messager] ~ Client ~ ${userID} joined room ${roomName} successfully!`);
31
31
  this.clients.set(userID, {
32
32
  roomName
33
33
  });
34
34
  });
35
35
  }
36
- sendFile(recipientId, fileName, fileData, filePath = process.cwd()) {
37
- this.clientTide.emitEvent(recipientId, "client-to-client-transfer", {
36
+ sendFile(clientID, recipientId, fileName, fileData, filePath = process.cwd()) {
37
+ this.clientTide.emitEvent(clientID, "client-to-client-transfer", {
38
38
  recipientId,
39
39
  fileName,
40
40
  fileData,
41
41
  filePath
42
42
  });
43
- console.log(`[FileTide ~ File Messager] ~ File ${fileName} sent to client ${recipientId}.`);
43
+ return;
44
44
  }
45
45
  onFileChunkReceived(userID) {
46
46
  this.clientTide.onEvent(userID, "transfer-progress", data => {
@@ -9,14 +9,12 @@ const path = require("path");
9
9
  const fs = require("fs");
10
10
  var _FileTide_brand = /*#__PURE__*/new WeakSet();
11
11
  class FileTide {
12
- constructor(config = {}) {
12
+ constructor() {
13
13
  /**
14
14
  * Set up file transfer event listeners natively.
15
15
  * Automatically checks and creates directories as needed.
16
16
  */
17
17
  _classPrivateMethodInitSpec(this, _FileTide_brand);
18
- this.config = config;
19
- this.fileNet = null;
20
18
  this.clients = new Map();
21
19
  return;
22
20
  }
@@ -33,6 +31,7 @@ class FileTide {
33
31
  if (onLaunch) {
34
32
  onLaunch(this.fileNet);
35
33
  }
34
+ return;
36
35
  }
37
36
 
38
37
  /**
@@ -44,10 +43,10 @@ class FileTide {
44
43
  */
45
44
  launchMessager(clientOptions = {}, roomName, userID, onLaunch, onIncomingFile) {
46
45
  if (this.clients.has(userID)) {
47
- console.log(`[FileTide] ~ Client ~ ${userID} already exists.`);
48
- return;
46
+ this.stopMessager(userID);
49
47
  }
50
48
  const newClient = new FileMessagerClient(clientOptions);
49
+ newClient.createClientInstance();
51
50
  newClient.joinRoom(userID, roomName);
52
51
  newClient.handleMultipleClientsTransfer();
53
52
  this.clients.set(userID, newClient);
@@ -153,4 +152,8 @@ function _setupFileEventListeners(userID, client, onIncomingFile) {
153
152
  return;
154
153
  }
155
154
  ;
155
+ const fileT = new FileTide();
156
+ fileT.launchFileTide({
157
+ port: 8869
158
+ });
156
159
  module.exports = FileTide;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
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": {