@trap_stevo/filetide 0.0.13 → 0.0.14
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.
package/dist/cjs/FileMessager.js
CHANGED
|
@@ -4,6 +4,9 @@ const IoTide = require("@trap_stevo/iotide");
|
|
|
4
4
|
const {
|
|
5
5
|
FileMessagerConfigManager
|
|
6
6
|
} = require("./HUDManagers/FileMessagerConfigManager");
|
|
7
|
+
const {
|
|
8
|
+
FileNetClientManager
|
|
9
|
+
} = require("./HUDManagers/FileNetClientManager");
|
|
7
10
|
const {
|
|
8
11
|
FileUtilityManager
|
|
9
12
|
} = require("./HUDManagers/FileUtilityManager");
|
|
@@ -11,7 +14,6 @@ class FileMessager {
|
|
|
11
14
|
constructor(options = {}) {
|
|
12
15
|
const serverOptions = FileMessagerConfigManager.getServerOptions(options);
|
|
13
16
|
this.fileNet = new IoTide(serverOptions.port, serverOptions, true, this.onConnect.bind(this), this.onDisconnect.bind(this));
|
|
14
|
-
this.messagerClients = new Map();
|
|
15
17
|
this.onlineClients = new Map();
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
@@ -44,12 +46,12 @@ class FileMessager {
|
|
|
44
46
|
* @param {String} fileName - The name of the file
|
|
45
47
|
*/
|
|
46
48
|
sendFileToClient(senderID, clientId, fileData, fileName, filePath = process.cwd()) {
|
|
47
|
-
if (!
|
|
49
|
+
if (!FileNetClientManager.getOnlineClient(clientId)) {
|
|
48
50
|
console.log(`Client ~ ${clientId} not authorized.`);
|
|
49
51
|
return;
|
|
50
52
|
}
|
|
51
|
-
const senderConnectionID =
|
|
52
|
-
const connectionID =
|
|
53
|
+
const senderConnectionID = FileNetClientManager.getOnlineClient(senderID);
|
|
54
|
+
const connectionID = FileNetClientManager.getOnlineClient(clientId);
|
|
53
55
|
const senderClient = this.onlineClients.get(connectionID);
|
|
54
56
|
const client = this.onlineClients.get(connectionID);
|
|
55
57
|
if (!client) {
|
|
@@ -88,11 +90,11 @@ class FileMessager {
|
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
92
|
handleClientsOnline(clientID) {
|
|
91
|
-
if (!
|
|
93
|
+
if (!FileNetClientManager.getOnlineClient(clientID)) {
|
|
92
94
|
console.log(`Client ~ ${clientID} not authorized.`);
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
95
|
-
const connectionID =
|
|
97
|
+
const connectionID = FileNetClientManager.getOnlineClient(clientID);
|
|
96
98
|
const client = this.onlineClients.get(connectionID);
|
|
97
99
|
if (!client) {
|
|
98
100
|
console.log(`Client ~ ${clientID} not found.`);
|
|
@@ -107,14 +109,16 @@ class FileMessager {
|
|
|
107
109
|
if (!this.onlineClients.has(connectionID)) {
|
|
108
110
|
return;
|
|
109
111
|
}
|
|
110
|
-
|
|
112
|
+
FileNetClientManager.addOnlineClient(clientID, "", connectionID);
|
|
113
|
+
console.log("Current online messagers: ", FileNetClientManager.getOnlineClients());
|
|
111
114
|
return;
|
|
112
115
|
}
|
|
113
116
|
handleClientOffline(clientID) {
|
|
114
|
-
if (!
|
|
117
|
+
if (!FileNetClientManager.getOnlineClient(clientID)) {
|
|
115
118
|
return;
|
|
116
119
|
}
|
|
117
|
-
|
|
120
|
+
FileNetClientManager.clearOnlineClient(clientID);
|
|
121
|
+
console.log(this.onlineClients, FileNetClientManager.getOnlineClients());
|
|
118
122
|
return;
|
|
119
123
|
}
|
|
120
124
|
handleFileTransferStart(fileData, emitToChannel) {
|
package/dist/cjs/FileTide.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
4
4
|
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
5
5
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
6
|
+
const {
|
|
7
|
+
FileNetConfigManager
|
|
8
|
+
} = require("./HUDManagers/FileNetConfigManager.js");
|
|
6
9
|
const FileMessagerClient = require("./FileMessagerClient");
|
|
7
10
|
const FileMessager = require("./FileMessager");
|
|
8
11
|
const path = require("path");
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const currentOnlineClients = new Map();
|
|
4
|
+
class FileNetClientManager {
|
|
5
|
+
static addOnlineClient(clientID, pClientID, tideID) {
|
|
6
|
+
if (currentOnlineClients.get(pClientID)) {
|
|
7
|
+
currentOnlineClients.delete(pClientID);
|
|
8
|
+
}
|
|
9
|
+
currentOnlineClients.set(clientID, {
|
|
10
|
+
pClientID: pClientID || "",
|
|
11
|
+
clientID,
|
|
12
|
+
tideID
|
|
13
|
+
});
|
|
14
|
+
return currentOnlineClients;
|
|
15
|
+
}
|
|
16
|
+
static clearOnlineClient(clientID) {
|
|
17
|
+
if (!currentOnlineClients.get(clientID)) {
|
|
18
|
+
return currentOnlineClients;
|
|
19
|
+
}
|
|
20
|
+
currentOnlineClients.delete(clientID);
|
|
21
|
+
return currentOnlineClients;
|
|
22
|
+
}
|
|
23
|
+
static getOnlineClient(clientID) {
|
|
24
|
+
return currentOnlineClients.get(clientID);
|
|
25
|
+
}
|
|
26
|
+
static getOnlineClients() {
|
|
27
|
+
return currentOnlineClients;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
module.exports = {
|
|
31
|
+
FileNetClientManager
|
|
32
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const currentOnlineClients = new Map();
|
|
4
|
+
class FileNetConfigManager {
|
|
5
|
+
static addOnlineClient(clientID, pClientID, tideID) {
|
|
6
|
+
if (currentOnlineClients.get(pClientID)) {
|
|
7
|
+
currentOnlineClients.delete(pClientID);
|
|
8
|
+
}
|
|
9
|
+
currentOnlineClients.set(clientID, {
|
|
10
|
+
pClientID: pClientID || "",
|
|
11
|
+
clientID,
|
|
12
|
+
tideID
|
|
13
|
+
});
|
|
14
|
+
return currentOnlineClients;
|
|
15
|
+
}
|
|
16
|
+
static clearOnlineClient(clientID, tideID) {
|
|
17
|
+
if (!currentOnlineClients.get(clientID)) {
|
|
18
|
+
return currentOnlineClients;
|
|
19
|
+
}
|
|
20
|
+
currentOnlineClients.delete(clientID);
|
|
21
|
+
return currentOnlineClients;
|
|
22
|
+
}
|
|
23
|
+
static getOnlineClient(clientID) {
|
|
24
|
+
if (!currentOnlineClients.get(clientID)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return currentOnlineClients.get(clientID);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
module.exports = {
|
|
31
|
+
FileNetConfigManager
|
|
32
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trap_stevo/filetide",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
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": {
|
package/test.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
oiyutryuihoj
|