@trap_stevo/filetide 0.0.40 → 0.0.41
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 +77 -17
- package/dist/cjs/FileMessagerClient.js +7 -5
- package/dist/cjs/FileTide.js +18 -3
- package/package.json +2 -2
- package/data.json +0 -355185
package/dist/cjs/FileMessager.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
const {
|
|
4
|
+
OmniMap
|
|
5
|
+
} = require("@trap_stevo/legendarybuilderpronodejs-utilities/HUDStructs");
|
|
3
6
|
const IoTide = require("@trap_stevo/iotide");
|
|
4
7
|
const {
|
|
5
8
|
FileMessagerConfigManager
|
|
@@ -26,22 +29,23 @@ class FileMessager {
|
|
|
26
29
|
this.clientTransferBarriers = new Map();
|
|
27
30
|
this.currentTidingTransfers = new Map();
|
|
28
31
|
this.fileNet = new IoTide(serverOptions.port, serverOptions, true, this.onConnect.bind(this), this.onDisconnect.bind(this));
|
|
29
|
-
this.onlineClients = new
|
|
32
|
+
this.onlineClients = new OmniMap();
|
|
30
33
|
return;
|
|
31
34
|
}
|
|
32
35
|
onConnect(socket) {
|
|
33
|
-
console.log(`Client connected
|
|
36
|
+
console.log(`Client connected ~ ${socket.id}`);
|
|
34
37
|
this.onlineClients.set(socket.id, socket);
|
|
35
38
|
return;
|
|
36
39
|
}
|
|
37
40
|
onDisconnect(connectionRes, socket) {
|
|
38
|
-
console.log(`Client disconnected
|
|
41
|
+
console.log(`Client disconnected ~ ${socket.id}`);
|
|
39
42
|
this.onlineClients.delete(socket.id);
|
|
40
43
|
return;
|
|
41
44
|
}
|
|
42
45
|
start() {
|
|
43
46
|
this.fileNet.on("get-client-transfer-barrier-response", this.handleClientTransferBarrierResponse.bind(this));
|
|
44
47
|
this.fileNet.on("get-client-transfer-state", this.handleGetClientTransferState.bind(this));
|
|
48
|
+
this.fileNet.on("get-client", this.handleGetClient.bind(this));
|
|
45
49
|
this.fileNet.on("notify-transfer-barrier", this.handleNotifyTransferBarrier.bind(this));
|
|
46
50
|
this.fileNet.on("send-current-transfer-state", this.handleSendCurrentTransferState.bind(this));
|
|
47
51
|
this.fileNet.on("send-file-list-to-client", this.handleSendFileListToClient.bind(this));
|
|
@@ -51,6 +55,7 @@ class FileMessager {
|
|
|
51
55
|
this.fileNet.on("transfer-complete", this.handleFileTransferComplete.bind(this));
|
|
52
56
|
this.fileNet.on("request-transfer-from-client", this.handleRequestTransferFromClient.bind(this));
|
|
53
57
|
this.fileNet.on("client-to-client-transfer", this.handleClientToClientTransfer.bind(this));
|
|
58
|
+
this.fileNet.on("check-client-online", this.handleCheckClientOnline.bind(this));
|
|
54
59
|
this.fileNet.on("client-offline", this.handleClientOffline.bind(this));
|
|
55
60
|
this.fileNet.on("clients-online", this.handleClientsOnline.bind(this));
|
|
56
61
|
this.fileNet.on("client-online", this.handleClientOnline.bind(this));
|
|
@@ -336,6 +341,22 @@ class FileMessager {
|
|
|
336
341
|
return;
|
|
337
342
|
}
|
|
338
343
|
}
|
|
344
|
+
handleGetClient(data) {
|
|
345
|
+
console.log(`[FileTide ~ Net] Getting client ~ ${data.clientID}...`);
|
|
346
|
+
try {
|
|
347
|
+
const senderConnectionID = FileNetClientManager.getOnlineClient(data.senderID).id;
|
|
348
|
+
const clientConnectionID = FileNetClientManager.getOnlineClient(data.clientID).id;
|
|
349
|
+
const senderClient = this.getClientFromID(clientConnectionID);
|
|
350
|
+
const client = this.getClientFromID(clientConnectionID);
|
|
351
|
+
if (!client || !senderClient) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
console.log(`[FileTide ~ Net] Got client ~ ${data.clientID}!`);
|
|
355
|
+
this.fileNet.emitToTide(senderClient.tideID, "retrieved-current-client", client);
|
|
356
|
+
} catch (error) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
339
360
|
handleNotifyTransferBarrier(data, emitToChannel) {
|
|
340
361
|
const accepted = data.accepted;
|
|
341
362
|
const transferID = data.data.transferID;
|
|
@@ -383,6 +404,30 @@ class FileMessager {
|
|
|
383
404
|
handleFileTransferComplete(data) {
|
|
384
405
|
console.log(`File transfer completed: ${data.fileName}`);
|
|
385
406
|
}
|
|
407
|
+
handleCheckClientOnline(data) {
|
|
408
|
+
console.log(`[FileTide ~ Net Activity] ~ Checking if client ~ ${data.clientID} online...`);
|
|
409
|
+
try {
|
|
410
|
+
const client = FileNetClientManager.getOnlineClient(data.clientID);
|
|
411
|
+
if (!client) {
|
|
412
|
+
this.fileNet.emit("retrieved-client-online", {
|
|
413
|
+
online: false,
|
|
414
|
+
client: null
|
|
415
|
+
});
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
console.log(`[FileTide ~ Net Activity] ~ Client ~ ${data.clientID} online!`);
|
|
419
|
+
this.fileNet.emit("retrieved-client-online", {
|
|
420
|
+
online: true,
|
|
421
|
+
client
|
|
422
|
+
});
|
|
423
|
+
} catch (error) {
|
|
424
|
+
this.fileNet.emit("retrieved-client-online", {
|
|
425
|
+
online: false,
|
|
426
|
+
client: null
|
|
427
|
+
});
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
386
431
|
handleClientsOnline(clientID) {
|
|
387
432
|
const connectionDetails = FileNetClientManager.getOnlineClient(clientID);
|
|
388
433
|
if (!connectionDetails) {
|
|
@@ -398,7 +443,12 @@ class FileMessager {
|
|
|
398
443
|
return;
|
|
399
444
|
}
|
|
400
445
|
handleClientOnline(clientID, tideID, pClientID, connectionID, activeTransferBarrier) {
|
|
401
|
-
if (!this.onlineClients.
|
|
446
|
+
if (!this.onlineClients.contains(connectionID)) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (FileNetClientManager.getOnlineClient(clientID) && this.onlineClients.get(connectionID)) {
|
|
450
|
+
clientID = `${clientID}_${connectionID.slice(0, 4)}`;
|
|
451
|
+
this.fileNet.emitToTide(tideID, "current-client-id-already-online", clientID);
|
|
402
452
|
return;
|
|
403
453
|
}
|
|
404
454
|
FileNetClientManager.addOnlineClient(clientID, pClientID, tideID, connectionID);
|
|
@@ -410,21 +460,31 @@ class FileMessager {
|
|
|
410
460
|
this.fileNet.emit("current-clients", Object.fromEntries(FileNetClientManager.getOnlineClients()));
|
|
411
461
|
return;
|
|
412
462
|
}
|
|
413
|
-
handleClientOffline(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
463
|
+
handleClientOffline(clientData) {
|
|
464
|
+
console.log(`Client ~ ${clientData.clientID} | connection origin ~ ${clientData.connectionID} going offline...`);
|
|
465
|
+
try {
|
|
466
|
+
const clientDetails = FileNetClientManager.getOnlineClient(clientData.clientID);
|
|
467
|
+
if (!clientDetails || clientDetails.id !== clientData.connectionID) {
|
|
468
|
+
console.log(!clientDetails ? `[FileTide ~ Net Activity] ~ Client ~ ${clientData.clientID} already offline.` : `[FileTide ~ Net Activity] ~ Unauthorized offline signal from connection ID ~ ${clientData.connectionID}.`);
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
FileNetClientManager.clearOnlineClient(clientData.clientID);
|
|
472
|
+
this.fileNet.emit("current-clients", Object.fromEntries(FileNetClientManager.getOnlineClients()));
|
|
473
|
+
this.fileNet.emit("save-current-transfer-states", {
|
|
474
|
+
clientID: clientData.clientID
|
|
475
|
+
});
|
|
476
|
+
const tidingTransfers = this.currentTidingTransfers.get(clientData.clientID);
|
|
477
|
+
if (tidingTransfers && tidingTransfers.size > 0) {
|
|
478
|
+
for (let recipientID of tidingTransfers.keys()) {
|
|
479
|
+
this.fileNet.emit("save-current-transfer-states", {
|
|
480
|
+
clientID: recipientID
|
|
481
|
+
});
|
|
482
|
+
}
|
|
425
483
|
}
|
|
484
|
+
this.currentTidingTransfers.delete(clientData.clientID);
|
|
485
|
+
} catch (error) {
|
|
486
|
+
console.log(`[FileTide ~ Net Activity] ~ Did not process client ~ ${clientData} offline signal ~ ${error}`);
|
|
426
487
|
}
|
|
427
|
-
this.currentTidingTransfers.delete(clientID);
|
|
428
488
|
return;
|
|
429
489
|
}
|
|
430
490
|
handleClientTiding(data) {
|
|
@@ -49,12 +49,14 @@ class FileMessagerClient {
|
|
|
49
49
|
const socketName = this.createClientInstance(userID, {
|
|
50
50
|
url: this.clientOptions.url
|
|
51
51
|
}, options, headers, onConnect, onDisconnect, authURL, authHeaders, useAuthentication, queryAuthToken);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
return () => {
|
|
53
|
+
this.clientTide.joinChannel(socketName, roomName, userID, () => {
|
|
54
|
+
FileNetUtilityManager.outputGradient(`\n[FileTide ~ File Messager] ~ Client ~ ${userID} joined room ${roomName} successfully!`, significantMessageColors);
|
|
55
|
+
this.clients.set(userID, {
|
|
56
|
+
roomName
|
|
57
|
+
});
|
|
56
58
|
});
|
|
57
|
-
}
|
|
59
|
+
};
|
|
58
60
|
}
|
|
59
61
|
async requestTransfer(clientID, senderID, filePath, destinationPath, filterContent = []) {
|
|
60
62
|
const transferAllowed = await this.allowedTransfer(clientID, senderID, destinationPath, "N/A", "requestSend");
|
package/dist/cjs/FileTide.js
CHANGED
|
@@ -90,14 +90,14 @@ class FileTide {
|
|
|
90
90
|
this.stopMessager(userID);
|
|
91
91
|
}
|
|
92
92
|
const newClient = new FileMessagerClient(clientOptions);
|
|
93
|
-
newClient.joinRoom(userID, roomName, connectionOptions, headers, onConnect, onDisconnect, authURL, authHeaders, useAuthentication, queryAuthToken);
|
|
93
|
+
const enterRoom = newClient.joinRoom(userID, roomName, connectionOptions, headers, onConnect, onDisconnect, authURL, authHeaders, useAuthentication, queryAuthToken);
|
|
94
94
|
this.transferBarrier = enableTransferBarrier;
|
|
95
95
|
this.clientShorePolicies.set(userID, [FileUtilityManager.getTidePath(">CurrentUser"), FileUtilityManager.getTidePath(">Downloads"), FileUtilityManager.getTidePath(">Documents")]);
|
|
96
96
|
this.clients.set(userID, newClient);
|
|
97
97
|
FileTide.outputGradient(`[FileTide] ~ Messager launched successfully for client ~ ${userID}!`, significantMessageColors);
|
|
98
98
|
_assertClassBrand(_FileTide_brand, this, _setupFileEventListeners).call(this, userID, newClient, onTransferProgress, onIncomingTransfer, onIncomingFile, onTransferBarrier, options);
|
|
99
99
|
if (onLaunch) {
|
|
100
|
-
onLaunch(newClient);
|
|
100
|
+
onLaunch(newClient, enterRoom);
|
|
101
101
|
}
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
@@ -235,6 +235,10 @@ class FileTide {
|
|
|
235
235
|
stopMessager(userID) {
|
|
236
236
|
if (this.clients.has(userID)) {
|
|
237
237
|
FileTide.outputGradient(`Stopping messager for user ${userID}...`, significantMessageColors);
|
|
238
|
+
const connectionOrigin = this.clients.get(userID);
|
|
239
|
+
if (connectionOrigin) {
|
|
240
|
+
connectionOrigin.clientTide.closeSocket(userID);
|
|
241
|
+
}
|
|
238
242
|
this.clients.delete(userID);
|
|
239
243
|
FileTide.outputGradient(`Stopped messager for user ${userID}.`, significantMessageColors);
|
|
240
244
|
return;
|
|
@@ -262,7 +266,8 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
262
266
|
onTransferStatus,
|
|
263
267
|
onListFiles,
|
|
264
268
|
onCurrentOnlineClients,
|
|
265
|
-
onClientTiding
|
|
269
|
+
onClientTiding,
|
|
270
|
+
onCurrentClientIDAlreadyOnline
|
|
266
271
|
} = options;
|
|
267
272
|
const cliTable = new ConsoleTable({
|
|
268
273
|
padding: 2,
|
|
@@ -328,6 +333,16 @@ function _setupFileEventListeners(userID, client, onTransferProgress, onIncoming
|
|
|
328
333
|
onCurrentOnlineClients(currentClients, false);
|
|
329
334
|
}
|
|
330
335
|
});
|
|
336
|
+
client.clientTide.onEvent(userID, "current-client-id-already-online", clientID => {
|
|
337
|
+
if (userID === clientID) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
_FileTide.outputGradient(`[FileTide ~ FileNet] ~ Client ~ ${userID} already online.`, significantMessageColors);
|
|
341
|
+
if (onCurrentClientIDAlreadyOnline) {
|
|
342
|
+
onCurrentClientIDAlreadyOnline(clientID);
|
|
343
|
+
}
|
|
344
|
+
return;
|
|
345
|
+
});
|
|
331
346
|
client.clientTide.onEvent(userID, "save-current-transfer-states", async data => {
|
|
332
347
|
this.saveTransferStates();
|
|
333
348
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trap_stevo/filetide",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
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": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@trap_stevo/iotide": "^0.0.37",
|
|
33
33
|
"@trap_stevo/iotide-client": "^0.0.23",
|
|
34
|
-
"@trap_stevo/legendarybuilderpronodejs-utilities": "^1.0.
|
|
34
|
+
"@trap_stevo/legendarybuilderpronodejs-utilities": "^1.0.42",
|
|
35
35
|
"chalk": "^4.1.2",
|
|
36
36
|
"readline": "^1.3.0"
|
|
37
37
|
},
|