@trap_stevo/filetide 0.0.9 → 0.0.11

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.
@@ -48,7 +48,9 @@ class FileMessager {
48
48
  console.log(`Client ~ ${clientId} not authorized.`);
49
49
  return;
50
50
  }
51
+ const senderConnectionID = this.messagerClients.get(senderID);
51
52
  const connectionID = this.messagerClients.get(clientId);
53
+ const senderClient = this.onlineClients.get(connectionID);
52
54
  const client = this.onlineClients.get(connectionID);
53
55
  if (!client) {
54
56
  console.log(`Client ~ ${clientId} not found.`);
@@ -59,12 +61,14 @@ class FileMessager {
59
61
  fileData,
60
62
  path: filePath
61
63
  });
62
- console.log(`[FileTide ~ File Messager] ~ File ${fileName} sent to client ${clientId}!`);
63
- this.fileNet.emitToTide(senderID, "transfer-status", {
64
- status: `[FileTide ~ File Messager] ~ File ${fileName} sent to client ${clientId}!`,
65
- recipientID: clientId,
66
- success: true
67
- });
64
+ console.log(`[FileTide ~ File Messager] ~ File ${fileName} sent to client ~ ${clientId}!`);
65
+ if (senderClient) {
66
+ senderClient.emit("transfer-status", {
67
+ status: `[FileTide ~ File Messager] ~ File ${fileName} sent to client ~ ${clientId}!`,
68
+ recipientID: clientId,
69
+ success: true
70
+ });
71
+ }
68
72
  return;
69
73
  }
70
74
 
@@ -83,8 +87,18 @@ class FileMessager {
83
87
  this.sendFileToClient(senderID, recipientId, fileData, fileName, filePath);
84
88
  return;
85
89
  }
86
- handleClientsOnline() {
87
- this.fileNet.emit("clients-online", {
90
+ handleClientsOnline(clientID) {
91
+ if (!this.messagerClients.has(clientID)) {
92
+ console.log(`Client ~ ${clientID} not authorized.`);
93
+ return;
94
+ }
95
+ const connectionID = this.messagerClients.get(clientID);
96
+ const client = this.onlineClients.get(connectionID);
97
+ if (!client) {
98
+ console.log(`Client ~ ${clientID} not found.`);
99
+ return;
100
+ }
101
+ client.emit("current-clients-online", {
88
102
  currentClients: this.messagerClients
89
103
  });
90
104
  return;
@@ -116,4 +130,5 @@ class FileMessager {
116
130
  return;
117
131
  }
118
132
  }
133
+ ;
119
134
  module.exports = FileMessager;
@@ -58,7 +58,7 @@ class FileMessagerClient {
58
58
  }
59
59
  handleIncomingFile(userID) {
60
60
  this.clientTide.onEvent(userID, "incoming-file", data => {
61
- console.log(`[FileTide ~ File Messager] ~ Received file for user ${userID}: ${data.fileName}.`);
61
+ console.log(`\n[FileTide ~ File Messager] ~ Received file for user ${userID}: ${data.fileName}.`);
62
62
  FileUtilityManager.saveFile(data.fileName, data.fileData, data.path, data.name);
63
63
  });
64
64
  }
@@ -69,4 +69,5 @@ class FileMessagerClient {
69
69
  });
70
70
  }
71
71
  }
72
+ ;
72
73
  module.exports = FileMessagerClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
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": {