@trap_stevo/filetide 0.0.85 → 0.0.86
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/SCL-1.0-Universal.md +228 -0
- package/dist/cjs/FileMessagerClient.js +134 -70
- package/dist/cjs/FileTide.js +163 -82
- package/dist/cjs/{FileMessager.js → FileTideAnchor.js} +444 -264
- package/dist/cjs/HUDManagers/EndpointManager.js +157 -0
- package/dist/cjs/HUDManagers/{FileNetClientManager.js → FileTideAnchorClientManager.js} +3 -2
- package/dist/cjs/HUDManagers/{FileNetUtilityManager.js → FileTideAnchorUtilityManager.js} +2 -2
- package/dist/cjs/HUDManagers/FileTideDebugUtilityManager.js +6 -0
- package/dist/cjs/HUDManagers/FileTideNetworkTrafficManager.js +419 -0
- package/dist/cjs/HUDManagers/FileTransferManager.js +90 -157
- package/dist/cjs/HUDManagers/FileTransferReceiverManager.js +169 -9
- package/dist/cjs/HUDManagers/FileTransferStatsManager.js +138 -0
- package/dist/cjs/HUDManagers/FileTransferTrackingManager.js +22 -0
- package/package.json +4 -5
- package/LICENSE.md +0 -79
- package/dist/cjs/HUDComponents/ConsoleProgressBarManager.js +0 -288
|
@@ -8,14 +8,14 @@ const {
|
|
|
8
8
|
} = require("@trap_stevo/legendarybuilderpronodejs-utilities/HUDStructs");
|
|
9
9
|
const IoTide = require("@trap_stevo/iotide");
|
|
10
10
|
const {
|
|
11
|
-
|
|
12
|
-
} = require("./HUDManagers/
|
|
11
|
+
FileTideAnchorUtilityManager
|
|
12
|
+
} = require("./HUDManagers/FileTideAnchorUtilityManager");
|
|
13
13
|
const {
|
|
14
|
-
|
|
15
|
-
} = require("./HUDManagers/
|
|
14
|
+
FileTideAnchorClientManager
|
|
15
|
+
} = require("./HUDManagers/FileTideAnchorClientManager");
|
|
16
16
|
const {
|
|
17
|
-
|
|
18
|
-
} = require("./HUDManagers/
|
|
17
|
+
FileMessagerConfigManager
|
|
18
|
+
} = require("./HUDManagers/FileMessagerConfigManager");
|
|
19
19
|
const {
|
|
20
20
|
FileTransferManager
|
|
21
21
|
} = require("./HUDManagers/FileTransferManager");
|
|
@@ -28,8 +28,8 @@ const HUDTargetQueue = require("./HUDManagers/HUDTargetQueueManager");
|
|
|
28
28
|
const {
|
|
29
29
|
tidalytics
|
|
30
30
|
} = require("./HUDManagers/TidalyticsManager");
|
|
31
|
-
var
|
|
32
|
-
class
|
|
31
|
+
var _FileTideAnchor_brand = /*#__PURE__*/new WeakSet();
|
|
32
|
+
class FileTideAnchor {
|
|
33
33
|
constructor(options = {
|
|
34
34
|
pingTimeout: 180000,
|
|
35
35
|
pingInterval: 60000
|
|
@@ -37,7 +37,7 @@ class FileMessager {
|
|
|
37
37
|
parallelChunks: 3,
|
|
38
38
|
maxRetries: 3
|
|
39
39
|
}, onTideAction = null, debugMode = false, tideSentinelOptions = {}) {
|
|
40
|
-
_classPrivateMethodInitSpec(this,
|
|
40
|
+
_classPrivateMethodInitSpec(this, _FileTideAnchor_brand);
|
|
41
41
|
const serverOptions = FileMessagerConfigManager.getServerOptions(options);
|
|
42
42
|
this.transporter = new FileTransferManager(transportOptions);
|
|
43
43
|
this.transferQueue = new HUDTargetQueue();
|
|
@@ -48,7 +48,7 @@ class FileMessager {
|
|
|
48
48
|
this.tideSentinel.registerEntryAddedHook((key, entryData) => {
|
|
49
49
|
console.log(key, entryData);
|
|
50
50
|
});
|
|
51
|
-
this.
|
|
51
|
+
this.anchor = new IoTide(serverOptions.port, serverOptions, true, this.onConnect.bind(this), this.onDisconnect.bind(this));
|
|
52
52
|
this.onlineClients = new OmniMap();
|
|
53
53
|
this.onTideAction = onTideAction ?? (() => {});
|
|
54
54
|
this.debugMode = debugMode;
|
|
@@ -64,7 +64,7 @@ class FileMessager {
|
|
|
64
64
|
}
|
|
65
65
|
onDisconnect(connectionRes, socket) {
|
|
66
66
|
console.log(`Client disconnected ~ ${socket.id}`);
|
|
67
|
-
const currentOnlineClient =
|
|
67
|
+
const currentOnlineClient = FileTideAnchorClientManager.getOnlineClientByConnectionID(socket.id);
|
|
68
68
|
if (currentOnlineClient) {
|
|
69
69
|
this.handleClientOffline({}, {
|
|
70
70
|
connectionID: currentOnlineClient.id,
|
|
@@ -75,28 +75,29 @@ class FileMessager {
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
close() {
|
|
78
|
-
this.
|
|
78
|
+
this.anchor.close();
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
start() {
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
this.
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
98
|
-
this.
|
|
99
|
-
this.
|
|
82
|
+
this.anchor.on("get-client-transfer-barrier-response", this.handleClientTransferBarrierResponse.bind(this));
|
|
83
|
+
this.anchor.on("get-client", this.handleGetClient.bind(this));
|
|
84
|
+
this.anchor.on("acknowledge-transfer-tide", this.handleAcknowledgeTransferTide.bind(this));
|
|
85
|
+
this.anchor.on("notify-transfer-barrier", this.handleNotifyTransferBarrier.bind(this));
|
|
86
|
+
this.anchor.on("sent-file-list-to-client", this.handleSentFileListToClient.bind(this));
|
|
87
|
+
this.anchor.on("send-file-list-to-client", this.handleSendFileListToClient.bind(this));
|
|
88
|
+
this.anchor.on("list-client-files", this.handleListClientFiles.bind(this));
|
|
89
|
+
this.anchor.on("transfer-start", this.handleFileTransferStart.bind(this));
|
|
90
|
+
this.anchor.on("transfer-progress", this.handleFileTransferProgress.bind(this));
|
|
91
|
+
this.anchor.on("transfer-complete", this.handleFileTransferComplete.bind(this));
|
|
92
|
+
this.anchor.on("transfer-failed", this.handleFileTransferFailed.bind(this));
|
|
93
|
+
this.anchor.on("request-transfer-from-client", this.handleRequestTransferFromClient.bind(this));
|
|
94
|
+
this.anchor.on("client-to-client-transfer", this.handleClientToClientTransfer.bind(this));
|
|
95
|
+
this.anchor.on("check-client-banned", this.handleCheckClientBanned.bind(this));
|
|
96
|
+
this.anchor.on("check-client-online", this.handleCheckClientOnline.bind(this));
|
|
97
|
+
this.anchor.on("client-offline", this.handleClientOffline.bind(this));
|
|
98
|
+
this.anchor.on("clients-online", this.handleClientsOnline.bind(this));
|
|
99
|
+
this.anchor.on("client-online", this.handleClientOnline.bind(this));
|
|
100
|
+
this.anchor.on("client-tiding", this.handleClientTiding.bind(this));
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
102
103
|
|
|
@@ -158,7 +159,7 @@ class FileMessager {
|
|
|
158
159
|
end = null
|
|
159
160
|
} = options;
|
|
160
161
|
const sources = ["storage", "memory"];
|
|
161
|
-
const fetch = _assertClassBrand(
|
|
162
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
162
163
|
const [storedOnline, storedOffline] = await Promise.all([fetch({
|
|
163
164
|
...filter,
|
|
164
165
|
tags: {
|
|
@@ -230,7 +231,7 @@ class FileMessager {
|
|
|
230
231
|
...chartConfig
|
|
231
232
|
};
|
|
232
233
|
const sources = ["storage", "memory"];
|
|
233
|
-
const fetch = _assertClassBrand(
|
|
234
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
234
235
|
const [alreadyOnlineEvents, onlineJoins] = await Promise.all([fetch({
|
|
235
236
|
...filter,
|
|
236
237
|
tags: {
|
|
@@ -291,7 +292,7 @@ class FileMessager {
|
|
|
291
292
|
...chartConfig
|
|
292
293
|
};
|
|
293
294
|
const sources = ["storage", "memory"];
|
|
294
|
-
const fetch = _assertClassBrand(
|
|
295
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
295
296
|
const [banned, kicked, unbanned] = await Promise.all([fetch({
|
|
296
297
|
...filter,
|
|
297
298
|
tags: {
|
|
@@ -346,7 +347,7 @@ class FileMessager {
|
|
|
346
347
|
...chartConfig
|
|
347
348
|
};
|
|
348
349
|
const sources = ["storage", "memory"];
|
|
349
|
-
const fetch = _assertClassBrand(
|
|
350
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
350
351
|
const [incomingTransfers, incoming, completed] = await Promise.all([fetch({
|
|
351
352
|
...filter,
|
|
352
353
|
tags: {
|
|
@@ -404,7 +405,7 @@ class FileMessager {
|
|
|
404
405
|
...chartConfig
|
|
405
406
|
};
|
|
406
407
|
const sources = ["storage", "memory"];
|
|
407
|
-
const fetch = _assertClassBrand(
|
|
408
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
408
409
|
const [transferStates] = await Promise.all([fetch({
|
|
409
410
|
...filter,
|
|
410
411
|
tags: {
|
|
@@ -443,7 +444,7 @@ class FileMessager {
|
|
|
443
444
|
...chartConfig
|
|
444
445
|
};
|
|
445
446
|
const sources = ["storage", "memory"];
|
|
446
|
-
const fetch = _assertClassBrand(
|
|
447
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
447
448
|
const [requested, received] = await Promise.all([fetch({
|
|
448
449
|
...filter,
|
|
449
450
|
tags: {
|
|
@@ -490,7 +491,7 @@ class FileMessager {
|
|
|
490
491
|
...chartConfig
|
|
491
492
|
};
|
|
492
493
|
const sources = ["storage", "memory"];
|
|
493
|
-
const fetch = _assertClassBrand(
|
|
494
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
494
495
|
const [accepted, denied] = await Promise.all([fetch({
|
|
495
496
|
...filter,
|
|
496
497
|
tags: {
|
|
@@ -840,7 +841,7 @@ class FileMessager {
|
|
|
840
841
|
start = null,
|
|
841
842
|
end = null
|
|
842
843
|
} = options;
|
|
843
|
-
const fetch = _assertClassBrand(
|
|
844
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
844
845
|
const rawMetrics = await fetch({
|
|
845
846
|
...filter,
|
|
846
847
|
tags: {
|
|
@@ -876,7 +877,7 @@ class FileMessager {
|
|
|
876
877
|
start = null,
|
|
877
878
|
end = null
|
|
878
879
|
} = options;
|
|
879
|
-
const fetch = _assertClassBrand(
|
|
880
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
880
881
|
const rawMetrics = await fetch({
|
|
881
882
|
...filter,
|
|
882
883
|
tags: {
|
|
@@ -915,7 +916,7 @@ class FileMessager {
|
|
|
915
916
|
start = null,
|
|
916
917
|
end = null
|
|
917
918
|
} = options;
|
|
918
|
-
const fetch = _assertClassBrand(
|
|
919
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
919
920
|
const rawMetrics = await fetch({
|
|
920
921
|
...filter,
|
|
921
922
|
tags: {
|
|
@@ -950,7 +951,7 @@ class FileMessager {
|
|
|
950
951
|
start = null,
|
|
951
952
|
end = null
|
|
952
953
|
} = options;
|
|
953
|
-
const fetch = _assertClassBrand(
|
|
954
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
954
955
|
const rawMetrics = await fetch({
|
|
955
956
|
...filter,
|
|
956
957
|
tags: {
|
|
@@ -984,7 +985,7 @@ class FileMessager {
|
|
|
984
985
|
start = null,
|
|
985
986
|
end = null
|
|
986
987
|
} = options;
|
|
987
|
-
const fetch = _assertClassBrand(
|
|
988
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
988
989
|
const rawMetrics = await fetch({
|
|
989
990
|
...filter,
|
|
990
991
|
tags: {
|
|
@@ -1021,7 +1022,7 @@ class FileMessager {
|
|
|
1021
1022
|
start = null,
|
|
1022
1023
|
end = null
|
|
1023
1024
|
} = options;
|
|
1024
|
-
const fetch = _assertClassBrand(
|
|
1025
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
1025
1026
|
const rawMetrics = await fetch({
|
|
1026
1027
|
...filter,
|
|
1027
1028
|
tags: {
|
|
@@ -1058,7 +1059,7 @@ class FileMessager {
|
|
|
1058
1059
|
start = null,
|
|
1059
1060
|
end = null
|
|
1060
1061
|
} = options;
|
|
1061
|
-
const fetch = _assertClassBrand(
|
|
1062
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
1062
1063
|
const rawMetrics = await fetch({
|
|
1063
1064
|
...filter,
|
|
1064
1065
|
tags: {
|
|
@@ -1090,7 +1091,7 @@ class FileMessager {
|
|
|
1090
1091
|
start = null,
|
|
1091
1092
|
end = null
|
|
1092
1093
|
} = options;
|
|
1093
|
-
const fetch = _assertClassBrand(
|
|
1094
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
1094
1095
|
const rawMetrics = await fetch({
|
|
1095
1096
|
...filter,
|
|
1096
1097
|
tags: {
|
|
@@ -1121,7 +1122,7 @@ class FileMessager {
|
|
|
1121
1122
|
start = null,
|
|
1122
1123
|
end = null
|
|
1123
1124
|
} = options;
|
|
1124
|
-
const fetch = _assertClassBrand(
|
|
1125
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
1125
1126
|
const rawMetrics = await fetch({
|
|
1126
1127
|
...filter,
|
|
1127
1128
|
tags: {
|
|
@@ -1151,7 +1152,7 @@ class FileMessager {
|
|
|
1151
1152
|
start = null,
|
|
1152
1153
|
end = null
|
|
1153
1154
|
} = options;
|
|
1154
|
-
const fetch = _assertClassBrand(
|
|
1155
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
1155
1156
|
const rawMetrics = await fetch({
|
|
1156
1157
|
...filter,
|
|
1157
1158
|
tags: {
|
|
@@ -1181,7 +1182,7 @@ class FileMessager {
|
|
|
1181
1182
|
start = null,
|
|
1182
1183
|
end = null
|
|
1183
1184
|
} = options;
|
|
1184
|
-
const fetch = _assertClassBrand(
|
|
1185
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
1185
1186
|
const rawMetrics = await fetch({
|
|
1186
1187
|
...filter,
|
|
1187
1188
|
tags: {
|
|
@@ -1210,7 +1211,7 @@ class FileMessager {
|
|
|
1210
1211
|
start = null,
|
|
1211
1212
|
end = null
|
|
1212
1213
|
} = options;
|
|
1213
|
-
const fetch = _assertClassBrand(
|
|
1214
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
1214
1215
|
const rawMetrics = await fetch({
|
|
1215
1216
|
...filter,
|
|
1216
1217
|
tags: {
|
|
@@ -1245,7 +1246,7 @@ class FileMessager {
|
|
|
1245
1246
|
start = null,
|
|
1246
1247
|
end = null
|
|
1247
1248
|
} = options;
|
|
1248
|
-
const fetch = _assertClassBrand(
|
|
1249
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
1249
1250
|
const rawMetrics = await fetch({
|
|
1250
1251
|
...filter,
|
|
1251
1252
|
tags: {
|
|
@@ -1280,7 +1281,7 @@ class FileMessager {
|
|
|
1280
1281
|
start = null,
|
|
1281
1282
|
end = null
|
|
1282
1283
|
} = options;
|
|
1283
|
-
const fetch = _assertClassBrand(
|
|
1284
|
+
const fetch = _assertClassBrand(_FileTideAnchor_brand, this, _getTidalyticsRangeFetcher).call(this, interval, rangeMode, start, end);
|
|
1284
1285
|
const rawMetrics = await fetch({
|
|
1285
1286
|
...filter,
|
|
1286
1287
|
tags: {
|
|
@@ -1442,7 +1443,7 @@ class FileMessager {
|
|
|
1442
1443
|
return client;
|
|
1443
1444
|
}
|
|
1444
1445
|
getClient(clientID) {
|
|
1445
|
-
const client =
|
|
1446
|
+
const client = FileTideAnchorClientManager.getOnlineClient(clientID);
|
|
1446
1447
|
if (!client) {
|
|
1447
1448
|
console.log(`Client ~ ${clientID} not found.`);
|
|
1448
1449
|
return;
|
|
@@ -1450,15 +1451,15 @@ class FileMessager {
|
|
|
1450
1451
|
return client;
|
|
1451
1452
|
}
|
|
1452
1453
|
getOnlineClients() {
|
|
1453
|
-
return
|
|
1454
|
+
return FileTideAnchorClientManager.getOnlineClients();
|
|
1454
1455
|
}
|
|
1455
1456
|
requestFromClient(requesterID, senderID, filePath = process.cwd(), destinationPath) {
|
|
1456
|
-
const senderConnectionID =
|
|
1457
|
+
const senderConnectionID = FileTideAnchorClientManager.getOnlineClient(senderID).id;
|
|
1457
1458
|
const client = this.getClientFromID(senderConnectionID);
|
|
1458
1459
|
if (!client) {
|
|
1459
1460
|
return;
|
|
1460
1461
|
}
|
|
1461
|
-
this.
|
|
1462
|
+
this.anchor.emitToTide(client.tideID, "transfer-requested", {
|
|
1462
1463
|
senderID,
|
|
1463
1464
|
requesterID,
|
|
1464
1465
|
path: filePath,
|
|
@@ -1483,7 +1484,7 @@ class FileMessager {
|
|
|
1483
1484
|
return;
|
|
1484
1485
|
}
|
|
1485
1486
|
if (chunkIndex === 0) {
|
|
1486
|
-
this.
|
|
1487
|
+
this.anchor.emitToTide(client.tideID, "incoming-file", {
|
|
1487
1488
|
senderID: senderData.userID,
|
|
1488
1489
|
clientID: clientData.userID,
|
|
1489
1490
|
fileName,
|
|
@@ -1529,7 +1530,7 @@ class FileMessager {
|
|
|
1529
1530
|
}
|
|
1530
1531
|
});
|
|
1531
1532
|
}
|
|
1532
|
-
this.
|
|
1533
|
+
this.anchor.emitToTide(client.tideID, "transfer-progress", {
|
|
1533
1534
|
senderName: senderData.userID,
|
|
1534
1535
|
senderID: senderData.id,
|
|
1535
1536
|
fileName,
|
|
@@ -1540,9 +1541,9 @@ class FileMessager {
|
|
|
1540
1541
|
fileSize,
|
|
1541
1542
|
metadata
|
|
1542
1543
|
});
|
|
1543
|
-
_assertClassBrand(
|
|
1544
|
+
_assertClassBrand(_FileTideAnchor_brand, this, _log).call(this, `[FileTide ~ Anchor Transporter] ~ Sent chunk ${chunkIndex} of ${fileName} to client ~ ${clientData.userID}!`);
|
|
1544
1545
|
if (senderClient) {
|
|
1545
|
-
this.
|
|
1546
|
+
this.anchor.emitToTide(senderClient.tideID, "transfer-status", {
|
|
1546
1547
|
status: `Chunk ${chunkIndex} of ${fileName} sent to client ${clientData.userID}!`,
|
|
1547
1548
|
recipientID: clientData.userID,
|
|
1548
1549
|
senderName: senderData.userID,
|
|
@@ -1578,14 +1579,14 @@ class FileMessager {
|
|
|
1578
1579
|
runningOn
|
|
1579
1580
|
} = listData;
|
|
1580
1581
|
try {
|
|
1581
|
-
const recipientConnectionID =
|
|
1582
|
-
const senderConnectionID =
|
|
1582
|
+
const recipientConnectionID = FileTideAnchorClientManager.getOnlineClient(recipientID).id;
|
|
1583
|
+
const senderConnectionID = FileTideAnchorClientManager.getOnlineClient(senderID).id;
|
|
1583
1584
|
const senderClient = this.getClientFromID(senderConnectionID);
|
|
1584
1585
|
const client = this.getClientFromID(recipientConnectionID);
|
|
1585
1586
|
if (!client || !senderClient) {
|
|
1586
1587
|
return;
|
|
1587
1588
|
}
|
|
1588
|
-
this.
|
|
1589
|
+
this.anchor.emitToTide(client.tideID, "client-file-list-received", {
|
|
1589
1590
|
senderID,
|
|
1590
1591
|
totalItemsSent,
|
|
1591
1592
|
runningOn
|
|
@@ -1618,7 +1619,7 @@ class FileMessager {
|
|
|
1618
1619
|
}
|
|
1619
1620
|
});
|
|
1620
1621
|
} catch (error) {
|
|
1621
|
-
console.error(`[FileTide ~
|
|
1622
|
+
console.error(`[FileTide ~ Anchor Scanner] ~ `, error);
|
|
1622
1623
|
return;
|
|
1623
1624
|
}
|
|
1624
1625
|
}
|
|
@@ -1631,21 +1632,21 @@ class FileMessager {
|
|
|
1631
1632
|
runningOn
|
|
1632
1633
|
} = listData;
|
|
1633
1634
|
try {
|
|
1634
|
-
const recipientConnectionID =
|
|
1635
|
-
const senderConnectionID =
|
|
1635
|
+
const recipientConnectionID = FileTideAnchorClientManager.getOnlineClient(recipientID).id;
|
|
1636
|
+
const senderConnectionID = FileTideAnchorClientManager.getOnlineClient(senderID).id;
|
|
1636
1637
|
const senderClient = this.getClientFromID(senderConnectionID);
|
|
1637
1638
|
const client = this.getClientFromID(recipientConnectionID);
|
|
1638
1639
|
if (!client || !senderClient) {
|
|
1639
1640
|
return;
|
|
1640
1641
|
}
|
|
1641
|
-
this.
|
|
1642
|
+
this.anchor.emitToTide(client.tideID, "client-file-list", {
|
|
1642
1643
|
senderID,
|
|
1643
1644
|
totalItems,
|
|
1644
1645
|
listedFiles,
|
|
1645
1646
|
runningOn
|
|
1646
1647
|
});
|
|
1647
1648
|
} catch (error) {
|
|
1648
|
-
console.error(`[FileTide ~
|
|
1649
|
+
console.error(`[FileTide ~ Anchor Scanner] ~ `, error);
|
|
1649
1650
|
return;
|
|
1650
1651
|
}
|
|
1651
1652
|
}
|
|
@@ -1656,14 +1657,14 @@ class FileMessager {
|
|
|
1656
1657
|
depth = 1
|
|
1657
1658
|
} = clientData;
|
|
1658
1659
|
try {
|
|
1659
|
-
const recipientConnectionID =
|
|
1660
|
-
const senderConnectionID =
|
|
1660
|
+
const recipientConnectionID = FileTideAnchorClientManager.getOnlineClient(recipientID).id;
|
|
1661
|
+
const senderConnectionID = FileTideAnchorClientManager.getOnlineClient(requesterID).id;
|
|
1661
1662
|
const senderClient = this.getClientFromID(senderConnectionID);
|
|
1662
1663
|
const client = this.getClientFromID(recipientConnectionID);
|
|
1663
1664
|
if (!client || !senderClient) {
|
|
1664
1665
|
return;
|
|
1665
1666
|
}
|
|
1666
|
-
this.
|
|
1667
|
+
this.anchor.emitToTide(client.tideID, "list-files", {
|
|
1667
1668
|
senderID: requesterID,
|
|
1668
1669
|
recipientID,
|
|
1669
1670
|
depth
|
|
@@ -1693,140 +1694,113 @@ class FileMessager {
|
|
|
1693
1694
|
}
|
|
1694
1695
|
});
|
|
1695
1696
|
} catch (error) {
|
|
1696
|
-
console.error(`[FileTide ~
|
|
1697
|
+
console.error(`[FileTide ~ Anchor Scanner] ~ `, error);
|
|
1697
1698
|
return;
|
|
1698
1699
|
}
|
|
1699
1700
|
}
|
|
1700
1701
|
handleClientToClientTransfer(senderTide, transferData) {
|
|
1701
1702
|
try {
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
fileSize,
|
|
1752
|
-
fileName
|
|
1753
|
-
},
|
|
1754
|
-
metadata: {
|
|
1755
|
-
recipientID: recipientId,
|
|
1756
|
-
senderID,
|
|
1757
|
-
path: filePath,
|
|
1758
|
-
fileSize,
|
|
1759
|
-
fileName,
|
|
1760
|
-
completedChunks,
|
|
1761
|
-
totalChunks,
|
|
1762
|
-
chunkSize,
|
|
1763
|
-
transferMetadata: metadata
|
|
1764
|
-
}
|
|
1765
|
-
});
|
|
1766
|
-
this.onTideAction({
|
|
1767
|
-
tideActionID: "tide-completed-transfer",
|
|
1768
|
-
tideActionDate: Date.now(),
|
|
1769
|
-
tideActionDetails: {
|
|
1770
|
-
recipientID: recipientId,
|
|
1771
|
-
senderID,
|
|
1772
|
-
path: filePath,
|
|
1773
|
-
fileSize,
|
|
1774
|
-
fileName,
|
|
1775
|
-
completedChunks,
|
|
1776
|
-
totalChunks,
|
|
1777
|
-
chunkSize,
|
|
1778
|
-
transferMetadata: metadata
|
|
1779
|
-
}
|
|
1780
|
-
});
|
|
1781
|
-
console.log(`[FileTide ~ File Messager] ~ File transfer completed: ${fileName} from ${senderID} to ${recipientId}`);
|
|
1782
|
-
const tidingTransfers = this.currentTidingTransfers.get(senderID);
|
|
1783
|
-
if (tidingTransfers) {
|
|
1784
|
-
tidingTransfers.delete(senderID);
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
return;
|
|
1703
|
+
let tide = transferData?.tide;
|
|
1704
|
+
if (!tide && Array.isArray(transferData?.chunkBatch) && transferData.chunkBatch.length > 0) {
|
|
1705
|
+
const legacyChunks = transferData.chunkBatch;
|
|
1706
|
+
const firstChunk = legacyChunks[0];
|
|
1707
|
+
const lastChunk = legacyChunks[legacyChunks.length - 1];
|
|
1708
|
+
tide = {
|
|
1709
|
+
transferId: firstChunk.transferId,
|
|
1710
|
+
senderID: firstChunk.senderID,
|
|
1711
|
+
recipientId: firstChunk.recipientId,
|
|
1712
|
+
fileName: firstChunk.fileName,
|
|
1713
|
+
filePath: firstChunk.filePath,
|
|
1714
|
+
fileSize: firstChunk.fileSize,
|
|
1715
|
+
totalChunks: firstChunk.totalChunks,
|
|
1716
|
+
firstChunkIndex: firstChunk.chunkIndex,
|
|
1717
|
+
lastChunkIndex: lastChunk.chunkIndex,
|
|
1718
|
+
completedChunks: lastChunk.completedChunks,
|
|
1719
|
+
tideChunkCount: legacyChunks.length,
|
|
1720
|
+
tideBytes: legacyChunks.reduce((total, chunk) => total + chunk.chunkSize, 0),
|
|
1721
|
+
chunks: legacyChunks.map(chunk => ({
|
|
1722
|
+
chunkIndex: chunk.chunkIndex,
|
|
1723
|
+
chunkSize: chunk.chunkSize,
|
|
1724
|
+
fileChunk: chunk.fileChunk
|
|
1725
|
+
})),
|
|
1726
|
+
metadata: firstChunk.metadata || {}
|
|
1727
|
+
};
|
|
1728
|
+
} else if (!tide && transferData?.fileChunk !== undefined) {
|
|
1729
|
+
tide = {
|
|
1730
|
+
transferId: transferData.transferId,
|
|
1731
|
+
senderID: transferData.senderID,
|
|
1732
|
+
recipientId: transferData.recipientId,
|
|
1733
|
+
fileName: transferData.fileName,
|
|
1734
|
+
filePath: transferData.filePath,
|
|
1735
|
+
fileSize: transferData.fileSize,
|
|
1736
|
+
totalChunks: transferData.totalChunks,
|
|
1737
|
+
firstChunkIndex: transferData.chunkIndex,
|
|
1738
|
+
lastChunkIndex: transferData.chunkIndex,
|
|
1739
|
+
completedChunks: transferData.completedChunks,
|
|
1740
|
+
tideChunkCount: 1,
|
|
1741
|
+
tideBytes: transferData.chunkSize,
|
|
1742
|
+
chunks: [{
|
|
1743
|
+
chunkIndex: transferData.chunkIndex,
|
|
1744
|
+
chunkSize: transferData.chunkSize,
|
|
1745
|
+
fileChunk: transferData.fileChunk
|
|
1746
|
+
}],
|
|
1747
|
+
metadata: transferData.metadata || {}
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
if (!tide || !Array.isArray(tide.chunks) || tide.chunks.length <= 0) {
|
|
1751
|
+
throw new Error("Received an invalid or empty transfer Tide.");
|
|
1789
1752
|
}
|
|
1790
1753
|
const {
|
|
1754
|
+
transferId,
|
|
1791
1755
|
senderID,
|
|
1792
1756
|
recipientId,
|
|
1793
1757
|
fileName,
|
|
1794
|
-
fileChunk,
|
|
1795
|
-
fileSize,
|
|
1796
1758
|
filePath,
|
|
1797
|
-
|
|
1798
|
-
chunkSize,
|
|
1799
|
-
completedChunks,
|
|
1759
|
+
fileSize,
|
|
1800
1760
|
totalChunks,
|
|
1761
|
+
firstChunkIndex,
|
|
1762
|
+
lastChunkIndex,
|
|
1763
|
+
completedChunks,
|
|
1764
|
+
tideChunkCount,
|
|
1765
|
+
tideBytes,
|
|
1766
|
+
chunks,
|
|
1801
1767
|
metadata = {}
|
|
1802
|
-
} =
|
|
1803
|
-
|
|
1804
|
-
const
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
this.
|
|
1768
|
+
} = tide;
|
|
1769
|
+
let expectedChunkIndex = firstChunkIndex;
|
|
1770
|
+
for (const chunk of chunks) {
|
|
1771
|
+
if (chunk.chunkIndex !== expectedChunkIndex) {
|
|
1772
|
+
throw new Error(`Tide ordering violation for ${fileName}. Expected chunk ${expectedChunkIndex}, received ${chunk.chunkIndex}.`);
|
|
1773
|
+
}
|
|
1774
|
+
expectedChunkIndex++;
|
|
1775
|
+
}
|
|
1776
|
+
if (chunks[0].chunkIndex !== firstChunkIndex || chunks[chunks.length - 1].chunkIndex !== lastChunkIndex) {
|
|
1777
|
+
throw new Error(`Tide boundary mismatch for ${fileName}.`);
|
|
1778
|
+
}
|
|
1779
|
+
const recipientClient = FileTideAnchorClientManager.getOnlineClient(recipientId);
|
|
1780
|
+
const senderClient = FileTideAnchorClientManager.getOnlineClient(senderID);
|
|
1781
|
+
if (!recipientClient || !senderClient) {
|
|
1782
|
+
throw new Error(`Both sender ${senderID} and recipient ${recipientId} must be online for Tide routing.`);
|
|
1783
|
+
}
|
|
1784
|
+
_assertClassBrand(_FileTideAnchor_brand, this, _log).call(this, `[FileTide ~ Anchor Transporter] ~ Routing Tide ~ ${fileName} | chunks ${firstChunkIndex + 1}-${lastChunkIndex + 1} >> ${completedChunks} of ${totalChunks} to client (${recipientId})`);
|
|
1785
|
+
if (firstChunkIndex === 0) {
|
|
1786
|
+
this.anchor.emitToTide(recipientClient.tideID, "incoming-file", {
|
|
1787
|
+
transferId,
|
|
1821
1788
|
senderID,
|
|
1789
|
+
clientID: recipientId,
|
|
1822
1790
|
recipientId,
|
|
1823
1791
|
fileName,
|
|
1824
|
-
|
|
1792
|
+
totalChunks,
|
|
1793
|
+
chunkIndex: 0,
|
|
1794
|
+
chunkSize: chunks[0].chunkSize,
|
|
1795
|
+
path: filePath,
|
|
1796
|
+
filePath,
|
|
1797
|
+
fileSize,
|
|
1798
|
+
metadata
|
|
1825
1799
|
});
|
|
1826
|
-
tidalytics.track("tide:
|
|
1800
|
+
tidalytics.track("tide:incoming-file", {
|
|
1827
1801
|
value: 1,
|
|
1828
1802
|
tags: {
|
|
1829
|
-
"tide:
|
|
1803
|
+
"tide:incoming-file": "tide:incoming-file",
|
|
1830
1804
|
"tide": "tide",
|
|
1831
1805
|
recipientID: recipientId,
|
|
1832
1806
|
senderID,
|
|
@@ -1835,61 +1809,59 @@ class FileMessager {
|
|
|
1835
1809
|
fileName
|
|
1836
1810
|
},
|
|
1837
1811
|
metadata: {
|
|
1812
|
+
transferId,
|
|
1838
1813
|
recipientID: recipientId,
|
|
1839
1814
|
senderID,
|
|
1840
1815
|
path: filePath,
|
|
1841
1816
|
fileSize,
|
|
1842
1817
|
fileName,
|
|
1843
|
-
completedChunks,
|
|
1844
1818
|
totalChunks,
|
|
1845
|
-
chunkSize,
|
|
1819
|
+
chunkSize: chunks[0].chunkSize,
|
|
1846
1820
|
transferMetadata: metadata
|
|
1847
1821
|
}
|
|
1848
1822
|
});
|
|
1849
1823
|
this.onTideAction({
|
|
1850
|
-
tideActionID: "tide-
|
|
1824
|
+
tideActionID: "tide-incoming-file",
|
|
1851
1825
|
tideActionDate: Date.now(),
|
|
1852
1826
|
tideActionDetails: {
|
|
1827
|
+
transferId,
|
|
1853
1828
|
recipientID: recipientId,
|
|
1854
1829
|
senderID,
|
|
1855
1830
|
path: filePath,
|
|
1856
1831
|
fileSize,
|
|
1857
1832
|
fileName,
|
|
1858
|
-
completedChunks,
|
|
1859
1833
|
totalChunks,
|
|
1860
|
-
chunkSize,
|
|
1834
|
+
chunkSize: chunks[0].chunkSize,
|
|
1861
1835
|
transferMetadata: metadata
|
|
1862
1836
|
}
|
|
1863
1837
|
});
|
|
1864
|
-
console.log(`[FileTide ~ File Messager] ~ File transfer completed: ${fileName} from ${senderID} to ${recipientId}`);
|
|
1865
|
-
const tidingTransfers = this.currentTidingTransfers.get(senderID);
|
|
1866
|
-
if (tidingTransfers) {
|
|
1867
|
-
tidingTransfers.delete(senderID);
|
|
1868
|
-
}
|
|
1869
1838
|
}
|
|
1839
|
+
this.anchor.emitToTide(recipientClient.tideID, "transfer-progress", {
|
|
1840
|
+
tide
|
|
1841
|
+
});
|
|
1870
1842
|
} catch (error) {
|
|
1871
|
-
console.error(`[FileTide ~
|
|
1843
|
+
console.error(`[FileTide ~ Anchor Transporter] ~ `, error);
|
|
1872
1844
|
return;
|
|
1873
1845
|
}
|
|
1874
1846
|
}
|
|
1875
1847
|
handleClientTransferBarrierResponse(senderTide, data) {
|
|
1876
|
-
console.log(`[FileTide ~
|
|
1848
|
+
console.log(`[FileTide ~ Anchor] Checking ${data.recipientID}'s transfer barrier for transfer ~ ${data.transferID}...`);
|
|
1877
1849
|
try {
|
|
1878
|
-
const recipientConnectionID =
|
|
1879
|
-
const senderConnectionID =
|
|
1850
|
+
const recipientConnectionID = FileTideAnchorClientManager.getOnlineClient(data.recipientID).id;
|
|
1851
|
+
const senderConnectionID = FileTideAnchorClientManager.getOnlineClient(data.clientID).id;
|
|
1880
1852
|
const senderClient = this.getClientFromID(senderConnectionID);
|
|
1881
1853
|
const client = this.getClientFromID(recipientConnectionID);
|
|
1882
1854
|
if (!client || !senderClient) {
|
|
1883
|
-
console.log(`[FileTide ~
|
|
1855
|
+
console.log(`[FileTide ~ Anchor Barrier] ~ Both, recipient and sender connection authorization required.`);
|
|
1884
1856
|
return;
|
|
1885
1857
|
}
|
|
1886
|
-
this.
|
|
1858
|
+
this.anchor.emitToTide(client.tideID, "queue-incoming-transfer", {
|
|
1887
1859
|
...data,
|
|
1888
1860
|
transferType: "send"
|
|
1889
1861
|
});
|
|
1890
1862
|
this.transferQueue.waitForData(data.transferID, () => this.currentTransferBarrierTransfers.get(data.transferID), [true, false], 100, data.transferExpirationTime && typeof data.transferExpirationTime === "number" ? data.transferExpirationTime : 30000).then(accepted => {
|
|
1891
|
-
console.log(`[FileTide ~
|
|
1892
|
-
this.
|
|
1863
|
+
console.log(`[FileTide ~ Anchor Barrier] ~ Transfer ${accepted ? "accepted!" : "denied."}`);
|
|
1864
|
+
this.anchor.emitToTide(senderClient.tideID, "transfer-barrier-response", accepted);
|
|
1893
1865
|
this.currentTransferBarrierTransfers.delete(data.transferID);
|
|
1894
1866
|
if (accepted) {
|
|
1895
1867
|
tidalytics.track("tide-barrier:accepted", {
|
|
@@ -1932,7 +1904,7 @@ class FileMessager {
|
|
|
1932
1904
|
tideOriginPath: data.originPath
|
|
1933
1905
|
}
|
|
1934
1906
|
});
|
|
1935
|
-
this.
|
|
1907
|
+
this.anchor.emitToTide(client.tideID, "accepted-transfer", {
|
|
1936
1908
|
accepted,
|
|
1937
1909
|
...data
|
|
1938
1910
|
});
|
|
@@ -1978,48 +1950,167 @@ class FileMessager {
|
|
|
1978
1950
|
tideOriginPath: data.originPath
|
|
1979
1951
|
}
|
|
1980
1952
|
});
|
|
1981
|
-
this.
|
|
1953
|
+
this.anchor.emitToTide(client.tideID, "denied-transfer", {
|
|
1982
1954
|
accepted,
|
|
1983
1955
|
...data
|
|
1984
1956
|
});
|
|
1985
1957
|
}).catch(error => {
|
|
1986
|
-
console.error(`[FileTide ~
|
|
1958
|
+
console.error(`[FileTide ~ Anchor Barrier] ~ ${error.message}`);
|
|
1987
1959
|
});
|
|
1988
1960
|
return;
|
|
1989
1961
|
} catch (error) {
|
|
1990
|
-
console.error(`[FileTide ~
|
|
1962
|
+
console.error(`[FileTide ~ Anchor Barrier] ~ `, error);
|
|
1991
1963
|
return;
|
|
1992
1964
|
}
|
|
1993
1965
|
}
|
|
1994
1966
|
handleGetClient(senderTide, data) {
|
|
1995
|
-
console.log(`[FileTide ~
|
|
1967
|
+
console.log(`[FileTide ~ Anchor] ~ Getting client ~ ${data.clientID}...`);
|
|
1996
1968
|
try {
|
|
1997
|
-
const senderConnectionID =
|
|
1998
|
-
const clientConnectionID =
|
|
1969
|
+
const senderConnectionID = FileTideAnchorClientManager.getOnlineClient(data.senderID).id;
|
|
1970
|
+
const clientConnectionID = FileTideAnchorClientManager.getOnlineClient(data.clientID).id;
|
|
1999
1971
|
const senderClient = this.getClientFromID(clientConnectionID);
|
|
2000
1972
|
const client = this.getClientFromID(clientConnectionID);
|
|
2001
1973
|
if (!client || !senderClient) {
|
|
2002
1974
|
return;
|
|
2003
1975
|
}
|
|
2004
|
-
console.log(`[FileTide ~
|
|
2005
|
-
this.
|
|
1976
|
+
console.log(`[FileTide ~ Anchor] Got client ~ ${data.clientID}!`);
|
|
1977
|
+
this.anchor.emitToTide(senderClient.tideID, "retrieved-current-client", client);
|
|
2006
1978
|
} catch (error) {
|
|
2007
|
-
console.error(`[FileTide ~
|
|
1979
|
+
console.error(`[FileTide ~ Anchor Activity] ~ `, error);
|
|
2008
1980
|
return;
|
|
2009
1981
|
}
|
|
2010
1982
|
}
|
|
2011
1983
|
handleAcknowledgeTransferTide(senderTide, data) {
|
|
2012
1984
|
try {
|
|
2013
|
-
const
|
|
2014
|
-
const
|
|
2015
|
-
const
|
|
2016
|
-
const
|
|
2017
|
-
const
|
|
2018
|
-
const
|
|
1985
|
+
const transferStats = data.transferStats || {};
|
|
1986
|
+
const transferETA = transferStats.timeLeft <= 0 ? "Now" : FileTideAnchorUtilityManager.convertSeconds(transferStats.timeLeft !== null && transferStats.timeLeft !== undefined ? transferStats.timeLeft.toFixed(2) : Infinity);
|
|
1987
|
+
const transferProgress = transferStats.progress !== null && transferStats.progress !== undefined ? transferStats.progress.toFixed(2) : "N/A";
|
|
1988
|
+
const currentTransferredSize = FileTideAnchorUtilityManager.getFormattedSize(transferStats.current, true);
|
|
1989
|
+
const transferSize = FileTideAnchorUtilityManager.getFormattedSize(transferStats.totalSize, true);
|
|
1990
|
+
const transferSpeed = FileTideAnchorUtilityManager.getFormattedSize(transferStats.speed, true);
|
|
1991
|
+
const transferStartTime = transferStats.startTime;
|
|
2019
1992
|
const transferMetadata = data.metadata;
|
|
2020
1993
|
const contentType = transferMetadata?.contentType ?? "file";
|
|
2021
1994
|
const fileName = data.fileName;
|
|
2022
|
-
|
|
1995
|
+
const throughputBps = Number(transferStats.speed);
|
|
1996
|
+
const senderDetails = data.senderName ? FileTideAnchorClientManager.getOnlineClient(data.senderName) : null;
|
|
1997
|
+
const recipientDetails = data.recipientName ? FileTideAnchorClientManager.getOnlineClient(data.recipientName) : null;
|
|
1998
|
+
const senderClient = senderDetails ? this.getClientFromID(senderDetails.id) : null;
|
|
1999
|
+
const recipientClient = recipientDetails ? this.getClientFromID(recipientDetails.id) : null;
|
|
2000
|
+
|
|
2001
|
+
/*
|
|
2002
|
+
* Sender progress reflects receiver-confirmed persistence,
|
|
2003
|
+
* not merely Anchor forwarding. This keeps the sender's
|
|
2004
|
+
* tracking aligned with the authoritative receiver state.
|
|
2005
|
+
*/
|
|
2006
|
+
if (senderClient) {
|
|
2007
|
+
this.anchor.emitToTide(senderClient.tideID, "transfer-status", {
|
|
2008
|
+
transferId: data.transferId,
|
|
2009
|
+
senderName: data.senderName,
|
|
2010
|
+
senderID: data.senderName,
|
|
2011
|
+
recipientID: data.recipientName,
|
|
2012
|
+
recipientId: data.recipientName,
|
|
2013
|
+
success: true,
|
|
2014
|
+
fileName,
|
|
2015
|
+
fileSize: data.fileSize ?? transferStats.totalSize,
|
|
2016
|
+
path: data.path,
|
|
2017
|
+
filePath: data.path,
|
|
2018
|
+
totalChunks: data.totalChunks,
|
|
2019
|
+
completedChunks: data.completedChunks,
|
|
2020
|
+
firstChunkIndex: data.firstChunkIndex,
|
|
2021
|
+
lastChunkIndex: data.lastChunkIndex,
|
|
2022
|
+
chunkIndex: data.lastChunkIndex,
|
|
2023
|
+
chunkSize: data.chunkSize,
|
|
2024
|
+
tideChunkCount: data.tideChunkCount,
|
|
2025
|
+
tideBytes: data.tideBytes,
|
|
2026
|
+
highestContiguousChunk: data.highestContiguousChunk,
|
|
2027
|
+
missingChunks: Array.isArray(data.missingChunks) ? data.missingChunks : [],
|
|
2028
|
+
metadata: transferMetadata
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
2031
|
+
if (Number.isFinite(throughputBps) && throughputBps > 0 && senderClient) {
|
|
2032
|
+
this.anchor.emitToTide(senderClient.tideID, "tide-network-sample", {
|
|
2033
|
+
transferId: data.transferId,
|
|
2034
|
+
transferStateID: data.transferStateID,
|
|
2035
|
+
senderID: data.senderName,
|
|
2036
|
+
recipientID: data.recipientName,
|
|
2037
|
+
fileName,
|
|
2038
|
+
path: data.path,
|
|
2039
|
+
throughputBps,
|
|
2040
|
+
progress: transferStats.progress,
|
|
2041
|
+
transferredBytes: transferStats.current,
|
|
2042
|
+
totalBytes: transferStats.totalSize,
|
|
2043
|
+
firstChunkIndex: data.firstChunkIndex,
|
|
2044
|
+
lastChunkIndex: data.lastChunkIndex,
|
|
2045
|
+
highestContiguousChunk: data.highestContiguousChunk,
|
|
2046
|
+
tideChunkCount: data.tideChunkCount,
|
|
2047
|
+
tideBytes: data.tideBytes,
|
|
2048
|
+
sampledOn: Date.now()
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
const missingChunks = Array.isArray(data.missingChunks) ? data.missingChunks : [];
|
|
2052
|
+
const receiverConfirmedComplete = Number.isInteger(data.totalChunks) && data.totalChunks > 0 && data.highestContiguousChunk === data.totalChunks - 1 && missingChunks.length === 0;
|
|
2053
|
+
if (receiverConfirmedComplete && senderClient && recipientClient) {
|
|
2054
|
+
const completionData = {
|
|
2055
|
+
transferId: data.transferId,
|
|
2056
|
+
senderID: data.senderName,
|
|
2057
|
+
recipientId: data.recipientName,
|
|
2058
|
+
fileName,
|
|
2059
|
+
filePath: data.path,
|
|
2060
|
+
completedChunks: data.completedChunks,
|
|
2061
|
+
totalChunks: data.totalChunks,
|
|
2062
|
+
highestContiguousChunk: data.highestContiguousChunk,
|
|
2063
|
+
metadata: transferMetadata
|
|
2064
|
+
};
|
|
2065
|
+
this.anchor.emitToTide(recipientClient.tideID, "transfer-complete", completionData);
|
|
2066
|
+
this.anchor.emitToTide(senderClient.tideID, "transfer-complete", completionData);
|
|
2067
|
+
tidalytics.track("tide:completed-transfer", {
|
|
2068
|
+
value: 1,
|
|
2069
|
+
tags: {
|
|
2070
|
+
"tide:completed-transfer": "tide:completed-transfer",
|
|
2071
|
+
"tide": "tide",
|
|
2072
|
+
recipientID: data.recipientName,
|
|
2073
|
+
senderID: data.senderName,
|
|
2074
|
+
path: data.path,
|
|
2075
|
+
fileName
|
|
2076
|
+
},
|
|
2077
|
+
metadata: {
|
|
2078
|
+
transferId: data.transferId,
|
|
2079
|
+
recipientID: data.recipientName,
|
|
2080
|
+
senderID: data.senderName,
|
|
2081
|
+
path: data.path,
|
|
2082
|
+
fileName,
|
|
2083
|
+
completedChunks: data.completedChunks,
|
|
2084
|
+
totalChunks: data.totalChunks,
|
|
2085
|
+
highestContiguousChunk: data.highestContiguousChunk,
|
|
2086
|
+
transferMetadata
|
|
2087
|
+
}
|
|
2088
|
+
});
|
|
2089
|
+
this.onTideAction({
|
|
2090
|
+
tideActionID: "tide-completed-transfer",
|
|
2091
|
+
tideActionDate: Date.now(),
|
|
2092
|
+
tideActionDetails: {
|
|
2093
|
+
transferId: data.transferId,
|
|
2094
|
+
recipientID: data.recipientName,
|
|
2095
|
+
senderID: data.senderName,
|
|
2096
|
+
path: data.path,
|
|
2097
|
+
fileName,
|
|
2098
|
+
completedChunks: data.completedChunks,
|
|
2099
|
+
totalChunks: data.totalChunks,
|
|
2100
|
+
highestContiguousChunk: data.highestContiguousChunk,
|
|
2101
|
+
transferMetadata
|
|
2102
|
+
}
|
|
2103
|
+
});
|
|
2104
|
+
console.log(`[FileTide ~ Anchor Transporter] ~ Receiver confirmed file transfer completion: ${fileName} from ${data.senderName} to ${data.recipientName}`);
|
|
2105
|
+
const tidingTransfers = this.currentTidingTransfers.get(data.senderName);
|
|
2106
|
+
if (tidingTransfers) {
|
|
2107
|
+
tidingTransfers.delete(data.recipientName);
|
|
2108
|
+
if (tidingTransfers.size <= 0) {
|
|
2109
|
+
this.currentTidingTransfers.delete(data.senderName);
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
console.log(`[FileTide ~ Anchor Activity] ~ ${data.recipientName} acknowledged Tide transfer from ${data.senderName}.\n\n\t~ [${fileName}-${transferStartTime}] ~\n\n\t\tFile Name ~ ${fileName}\n\t\tDestination ~ ${data.path}\n\n\t\t\tChunks ~ ${data.firstChunkIndex}-${data.lastChunkIndex}\n\t\t\tHighest Contiguous Chunk ~ ${data.highestContiguousChunk}\n\t\t\tProgress ~ ${transferProgress}%\n\t\t\tETA ~ ${transferETA}\n\t\t\tSpeed ~ ${transferSpeed}/s\n\t\t\tSize ~ ${transferSize}\n\t\t\tTransferred ~ ${currentTransferredSize}\n`);
|
|
2023
2114
|
tidalytics.track("tide:transfer-state", {
|
|
2024
2115
|
value: 1,
|
|
2025
2116
|
tags: {
|
|
@@ -2035,6 +2126,7 @@ class FileMessager {
|
|
|
2035
2126
|
fileName
|
|
2036
2127
|
},
|
|
2037
2128
|
metadata: {
|
|
2129
|
+
transferId: data.transferId,
|
|
2038
2130
|
transferStateID: data.transferStateID,
|
|
2039
2131
|
recipientID: data.recipientName,
|
|
2040
2132
|
senderID: data.senderName,
|
|
@@ -2042,9 +2134,16 @@ class FileMessager {
|
|
|
2042
2134
|
startTime: transferStartTime,
|
|
2043
2135
|
currentTransferredSize,
|
|
2044
2136
|
speed: transferSpeed,
|
|
2137
|
+
throughputBps,
|
|
2045
2138
|
transferProgress,
|
|
2046
2139
|
transferSize,
|
|
2047
2140
|
transferETA,
|
|
2141
|
+
firstChunkIndex: data.firstChunkIndex,
|
|
2142
|
+
lastChunkIndex: data.lastChunkIndex,
|
|
2143
|
+
highestContiguousChunk: data.highestContiguousChunk,
|
|
2144
|
+
tideChunkCount: data.tideChunkCount,
|
|
2145
|
+
tideBytes: data.tideBytes,
|
|
2146
|
+
missingChunks,
|
|
2048
2147
|
fileName,
|
|
2049
2148
|
transferMetadata
|
|
2050
2149
|
}
|
|
@@ -2053,6 +2152,7 @@ class FileMessager {
|
|
|
2053
2152
|
tideActionID: "tide-transfer-state",
|
|
2054
2153
|
tideActionDate: Date.now(),
|
|
2055
2154
|
tideActionDetails: {
|
|
2155
|
+
transferId: data.transferId,
|
|
2056
2156
|
transferStateID: data.transferStateID,
|
|
2057
2157
|
recipientID: data.recipientName,
|
|
2058
2158
|
senderID: data.senderName,
|
|
@@ -2060,16 +2160,23 @@ class FileMessager {
|
|
|
2060
2160
|
startTime: transferStartTime,
|
|
2061
2161
|
currentTransferredSize,
|
|
2062
2162
|
speed: transferSpeed,
|
|
2163
|
+
throughputBps,
|
|
2063
2164
|
transferProgress,
|
|
2064
2165
|
transferSize,
|
|
2065
2166
|
transferETA,
|
|
2167
|
+
firstChunkIndex: data.firstChunkIndex,
|
|
2168
|
+
lastChunkIndex: data.lastChunkIndex,
|
|
2169
|
+
highestContiguousChunk: data.highestContiguousChunk,
|
|
2170
|
+
tideChunkCount: data.tideChunkCount,
|
|
2171
|
+
tideBytes: data.tideBytes,
|
|
2172
|
+
missingChunks,
|
|
2066
2173
|
contentType,
|
|
2067
2174
|
fileName,
|
|
2068
2175
|
transferMetadata
|
|
2069
2176
|
}
|
|
2070
2177
|
});
|
|
2071
2178
|
} catch (error) {
|
|
2072
|
-
console.error(`[FileTide ~
|
|
2179
|
+
console.error(`[FileTide ~ Anchor Activity] ~ ${data.recipientName} acknowledged Tide transfer from ${data.senderName}.\n\n${error}`);
|
|
2073
2180
|
}
|
|
2074
2181
|
}
|
|
2075
2182
|
handleNotifyTransferBarrier(senderTide, data, emitToChannel) {
|
|
@@ -2078,17 +2185,17 @@ class FileMessager {
|
|
|
2078
2185
|
this.currentTransferBarrierTransfers.set(transferID, accepted);
|
|
2079
2186
|
}
|
|
2080
2187
|
handleFileTransferStart(senderTide, data, emitToChannel) {
|
|
2081
|
-
console.log(`[FileTide ~
|
|
2188
|
+
console.log(`[FileTide ~ Anchor Transporter] ~ Alerting client of incoming transfer from ${data.senderID}...`);
|
|
2082
2189
|
try {
|
|
2083
|
-
const recipientConnectionID =
|
|
2084
|
-
const senderConnectionID =
|
|
2190
|
+
const recipientConnectionID = FileTideAnchorClientManager.getOnlineClient(data.recipientID).id;
|
|
2191
|
+
const senderConnectionID = FileTideAnchorClientManager.getOnlineClient(data.senderID).id;
|
|
2085
2192
|
const senderClient = this.getClientFromID(senderConnectionID);
|
|
2086
2193
|
const client = this.getClientFromID(recipientConnectionID);
|
|
2087
2194
|
if (!client || !senderClient) {
|
|
2088
2195
|
return;
|
|
2089
2196
|
}
|
|
2090
|
-
this.
|
|
2091
|
-
this.
|
|
2197
|
+
this.anchor.emitToTide(client.tideID, "incoming-transfer", data);
|
|
2198
|
+
this.anchor.emitToTide(senderClient.tideID, "incoming-transfer", {
|
|
2092
2199
|
...data,
|
|
2093
2200
|
currentSender: data.senderID
|
|
2094
2201
|
});
|
|
@@ -2144,7 +2251,7 @@ class FileMessager {
|
|
|
2144
2251
|
path: data.path
|
|
2145
2252
|
});
|
|
2146
2253
|
} catch (error) {
|
|
2147
|
-
console.error(`[FileTide ~
|
|
2254
|
+
console.error(`[FileTide ~ Anchor Transfers] ~ `, error);
|
|
2148
2255
|
return;
|
|
2149
2256
|
}
|
|
2150
2257
|
}
|
|
@@ -2154,13 +2261,86 @@ class FileMessager {
|
|
|
2154
2261
|
handleFileTransferComplete(senderTide, data) {
|
|
2155
2262
|
console.log(`File transfer completed: ${data.fileName}`);
|
|
2156
2263
|
}
|
|
2264
|
+
handleFileTransferFailed(senderTide, data) {
|
|
2265
|
+
try {
|
|
2266
|
+
const {
|
|
2267
|
+
transferId,
|
|
2268
|
+
senderID,
|
|
2269
|
+
recipientId,
|
|
2270
|
+
fileName,
|
|
2271
|
+
filePath,
|
|
2272
|
+
reason,
|
|
2273
|
+
metadata = {}
|
|
2274
|
+
} = data;
|
|
2275
|
+
const recipientClient = FileTideAnchorClientManager.getOnlineClient(recipientId);
|
|
2276
|
+
const senderClient = FileTideAnchorClientManager.getOnlineClient(senderID);
|
|
2277
|
+
const failureData = {
|
|
2278
|
+
transferId,
|
|
2279
|
+
senderID,
|
|
2280
|
+
recipientId,
|
|
2281
|
+
fileName,
|
|
2282
|
+
filePath,
|
|
2283
|
+
reason,
|
|
2284
|
+
metadata
|
|
2285
|
+
};
|
|
2286
|
+
if (recipientClient) {
|
|
2287
|
+
this.anchor.emitToTide(recipientClient.tideID, "transfer-failed", failureData);
|
|
2288
|
+
}
|
|
2289
|
+
if (senderClient) {
|
|
2290
|
+
this.anchor.emitToTide(senderClient.tideID, "transfer-failed", failureData);
|
|
2291
|
+
}
|
|
2292
|
+
const tidingTransfers = this.currentTidingTransfers.get(senderID);
|
|
2293
|
+
if (tidingTransfers) {
|
|
2294
|
+
tidingTransfers.delete(recipientId);
|
|
2295
|
+
if (tidingTransfers.size <= 0) {
|
|
2296
|
+
this.currentTidingTransfers.delete(senderID);
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
tidalytics.track("tide:failed-transfer", {
|
|
2300
|
+
value: 1,
|
|
2301
|
+
tags: {
|
|
2302
|
+
"tide:failed-transfer": "tide:failed-transfer",
|
|
2303
|
+
"tide": "tide",
|
|
2304
|
+
recipientID: recipientId,
|
|
2305
|
+
senderID,
|
|
2306
|
+
path: filePath,
|
|
2307
|
+
fileName
|
|
2308
|
+
},
|
|
2309
|
+
metadata: {
|
|
2310
|
+
transferId,
|
|
2311
|
+
recipientID: recipientId,
|
|
2312
|
+
senderID,
|
|
2313
|
+
path: filePath,
|
|
2314
|
+
fileName,
|
|
2315
|
+
reason,
|
|
2316
|
+
transferMetadata: metadata
|
|
2317
|
+
}
|
|
2318
|
+
});
|
|
2319
|
+
this.onTideAction({
|
|
2320
|
+
tideActionID: "tide-failed-transfer",
|
|
2321
|
+
tideActionDate: Date.now(),
|
|
2322
|
+
tideActionDetails: {
|
|
2323
|
+
transferId,
|
|
2324
|
+
recipientID: recipientId,
|
|
2325
|
+
senderID,
|
|
2326
|
+
path: filePath,
|
|
2327
|
+
fileName,
|
|
2328
|
+
reason,
|
|
2329
|
+
transferMetadata: metadata
|
|
2330
|
+
}
|
|
2331
|
+
});
|
|
2332
|
+
console.error(`[FileTide ~ Anchor Transporter] ~ File transfer failed: ${fileName} from ${senderID} to ${recipientId} ~ ${reason}`);
|
|
2333
|
+
} catch (error) {
|
|
2334
|
+
console.error(`[FileTide ~ Anchor Transfers] ~ Did not process failed transfer ~`, error);
|
|
2335
|
+
}
|
|
2336
|
+
}
|
|
2157
2337
|
async handleCheckClientBanned(senderTide, data) {
|
|
2158
|
-
console.log(`[FileTide ~
|
|
2338
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Checking if client ~ ${data.clientID} banned...`);
|
|
2159
2339
|
try {
|
|
2160
2340
|
const clientBanned = await this.clientBanned(data.tideID);
|
|
2161
2341
|
if (!clientBanned) {
|
|
2162
|
-
console.log(`[FileTide ~
|
|
2163
|
-
this.
|
|
2342
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Client ~ ${data.clientID} access authorized!`);
|
|
2343
|
+
this.anchor.emit("retrieved-client-banned", {
|
|
2164
2344
|
banned: false,
|
|
2165
2345
|
clientID: data.clientID,
|
|
2166
2346
|
tideID: data.tideID,
|
|
@@ -2168,18 +2348,18 @@ class FileMessager {
|
|
|
2168
2348
|
});
|
|
2169
2349
|
return;
|
|
2170
2350
|
}
|
|
2171
|
-
console.log(`[FileTide ~
|
|
2351
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Client ~ ${data.clientID} banned.`);
|
|
2172
2352
|
const bannedClientDetails = await this.getBanEntry(data.tideID);
|
|
2173
|
-
|
|
2353
|
+
FileTideAnchorClientManager.clearOnlineClient(data.clientID);
|
|
2174
2354
|
this.saveClientTransferStates(data);
|
|
2175
|
-
this.
|
|
2355
|
+
this.anchor.emit("retrieved-client-banned", {
|
|
2176
2356
|
banned: true,
|
|
2177
2357
|
clientID: data.clientID,
|
|
2178
2358
|
tideID: data.tideID,
|
|
2179
2359
|
bannedDetails: bannedClientDetails
|
|
2180
2360
|
});
|
|
2181
2361
|
} catch (error) {
|
|
2182
|
-
this.
|
|
2362
|
+
this.anchor.emit("retrieved-client-banned", {
|
|
2183
2363
|
banned: false,
|
|
2184
2364
|
clientID: data.clientID,
|
|
2185
2365
|
tideID: data.tideID,
|
|
@@ -2189,23 +2369,23 @@ class FileMessager {
|
|
|
2189
2369
|
}
|
|
2190
2370
|
}
|
|
2191
2371
|
handleCheckClientOnline(senderTide, data) {
|
|
2192
|
-
console.log(`[FileTide ~
|
|
2372
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Checking if client ~ ${data.clientID} online...`);
|
|
2193
2373
|
try {
|
|
2194
|
-
const client =
|
|
2374
|
+
const client = FileTideAnchorClientManager.getOnlineClient(data.clientID);
|
|
2195
2375
|
if (!client) {
|
|
2196
|
-
this.
|
|
2376
|
+
this.anchor.emit("retrieved-client-online", {
|
|
2197
2377
|
online: false,
|
|
2198
2378
|
client: null
|
|
2199
2379
|
});
|
|
2200
2380
|
return;
|
|
2201
2381
|
}
|
|
2202
|
-
console.log(`[FileTide ~
|
|
2203
|
-
this.
|
|
2382
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Client ~ ${data.clientID} online!`);
|
|
2383
|
+
this.anchor.emit("retrieved-client-online", {
|
|
2204
2384
|
online: true,
|
|
2205
2385
|
client
|
|
2206
2386
|
});
|
|
2207
2387
|
} catch (error) {
|
|
2208
|
-
this.
|
|
2388
|
+
this.anchor.emit("retrieved-client-online", {
|
|
2209
2389
|
online: false,
|
|
2210
2390
|
client: null
|
|
2211
2391
|
});
|
|
@@ -2213,28 +2393,28 @@ class FileMessager {
|
|
|
2213
2393
|
}
|
|
2214
2394
|
}
|
|
2215
2395
|
handleClientsOnline(senderTide, clientID) {
|
|
2216
|
-
const connectionDetails =
|
|
2396
|
+
const connectionDetails = FileTideAnchorClientManager.getOnlineClient(clientID);
|
|
2217
2397
|
if (!connectionDetails) {
|
|
2218
|
-
console.log(`[FileTide ~
|
|
2398
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Client ~ ${clientID} not authorized.`);
|
|
2219
2399
|
return;
|
|
2220
2400
|
}
|
|
2221
2401
|
const client = this.onlineClients.get(connectionDetails.id);
|
|
2222
2402
|
if (!client) {
|
|
2223
|
-
console.log(`[FileTide ~
|
|
2403
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Client ~ ${clientID} not found.`);
|
|
2224
2404
|
return;
|
|
2225
2405
|
}
|
|
2226
|
-
this.
|
|
2406
|
+
this.anchor.emitToTide(connectionDetails.tideID, "current-online-clients", Object.fromEntries(FileTideAnchorClientManager.getOnlineClients()));
|
|
2227
2407
|
return;
|
|
2228
2408
|
}
|
|
2229
2409
|
handleClientOnline(senderTide, clientID, tideID, pClientID, connectionID, activeTransferBarrier, originClientID, currentTideChannel) {
|
|
2230
2410
|
if (!this.onlineClients.contains(connectionID)) {
|
|
2231
2411
|
return;
|
|
2232
2412
|
}
|
|
2233
|
-
if (
|
|
2413
|
+
if (FileTideAnchorClientManager.getOnlineClient(clientID) && this.onlineClients.get(connectionID)) {
|
|
2234
2414
|
const nClientID = `${clientID}_${connectionID.slice(0, 4)}`;
|
|
2235
2415
|
const currentClientID = clientID;
|
|
2236
2416
|
clientID = nClientID;
|
|
2237
|
-
this.
|
|
2417
|
+
this.anchor.emitToTide(tideID, "current-client-id-already-online", clientID);
|
|
2238
2418
|
tidalytics.track("tider:already-online", {
|
|
2239
2419
|
value: 1,
|
|
2240
2420
|
tags: {
|
|
@@ -2269,7 +2449,7 @@ class FileMessager {
|
|
|
2269
2449
|
connectedOn: Date.now()
|
|
2270
2450
|
}
|
|
2271
2451
|
});
|
|
2272
|
-
|
|
2452
|
+
FileTideAnchorClientManager.updateOnlineClient(nClientID, {
|
|
2273
2453
|
pClientID: currentClientID,
|
|
2274
2454
|
clientID: nClientID,
|
|
2275
2455
|
tideID: senderTide.tideID,
|
|
@@ -2312,7 +2492,7 @@ class FileMessager {
|
|
|
2312
2492
|
tideID
|
|
2313
2493
|
}
|
|
2314
2494
|
});
|
|
2315
|
-
|
|
2495
|
+
FileTideAnchorClientManager.addOnlineClient(clientID, pClientID, tideID, connectionID, {
|
|
2316
2496
|
connectedOn: Date.now(),
|
|
2317
2497
|
currentTideChannel: currentTideChannel || "file-room",
|
|
2318
2498
|
originClientID
|
|
@@ -2321,17 +2501,17 @@ class FileMessager {
|
|
|
2321
2501
|
clientID,
|
|
2322
2502
|
activeTransferBarrier
|
|
2323
2503
|
});
|
|
2324
|
-
const currentOnlineClients = Object.fromEntries(
|
|
2325
|
-
this.
|
|
2326
|
-
this.
|
|
2504
|
+
const currentOnlineClients = Object.fromEntries(FileTideAnchorClientManager.getOnlineClients());
|
|
2505
|
+
this.anchor.emit("current-online-clients", currentOnlineClients);
|
|
2506
|
+
this.anchor.emit("current-clients", currentOnlineClients);
|
|
2327
2507
|
return;
|
|
2328
2508
|
}
|
|
2329
2509
|
handleClientOffline(senderTide, clientData) {
|
|
2330
|
-
console.log(`[FileTide ~
|
|
2510
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Client ~ ${clientData.clientID} | connection origin ~ ${clientData.connectionID} going offline...`);
|
|
2331
2511
|
try {
|
|
2332
|
-
const clientDetails =
|
|
2512
|
+
const clientDetails = FileTideAnchorClientManager.getOnlineClient(clientData.clientID);
|
|
2333
2513
|
if (!clientDetails || clientDetails.id !== clientData.connectionID) {
|
|
2334
|
-
console.log(!clientDetails ? `[FileTide ~
|
|
2514
|
+
console.log(!clientDetails ? `[FileTide ~ Anchor Activity] ~ Client ~ ${clientData.clientID} already offline.` : `[FileTide ~ Anchor Activity] ~ Unauthorized offline signal from connection ID ~ ${clientData.connectionID}.`);
|
|
2335
2515
|
return;
|
|
2336
2516
|
}
|
|
2337
2517
|
tidalytics.track("tider:offline", {
|
|
@@ -2366,29 +2546,29 @@ class FileMessager {
|
|
|
2366
2546
|
connectedOn: clientDetails.connectedOn
|
|
2367
2547
|
}
|
|
2368
2548
|
});
|
|
2369
|
-
|
|
2370
|
-
const currentOnlineClients = Object.fromEntries(
|
|
2371
|
-
this.
|
|
2372
|
-
this.
|
|
2549
|
+
FileTideAnchorClientManager.clearOnlineClient(clientData.clientID);
|
|
2550
|
+
const currentOnlineClients = Object.fromEntries(FileTideAnchorClientManager.getOnlineClients());
|
|
2551
|
+
this.anchor.emit("current-online-clients", currentOnlineClients);
|
|
2552
|
+
this.anchor.emit("current-clients", currentOnlineClients);
|
|
2373
2553
|
} catch (error) {
|
|
2374
|
-
console.log(`[FileTide ~
|
|
2554
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Did not process client ~ ${clientData} offline signal ~ ${error}`);
|
|
2375
2555
|
}
|
|
2376
2556
|
return;
|
|
2377
2557
|
}
|
|
2378
2558
|
handleClientTiding(senderTide, data) {
|
|
2379
2559
|
try {
|
|
2380
|
-
const senderConnectionID =
|
|
2560
|
+
const senderConnectionID = FileTideAnchorClientManager.getOnlineClient(data.senderID).id;
|
|
2381
2561
|
const senderClient = this.getClientFromID(senderConnectionID);
|
|
2382
2562
|
if (!senderClient) {
|
|
2383
2563
|
return;
|
|
2384
2564
|
}
|
|
2385
|
-
console.log(`[FileTide ~
|
|
2386
|
-
this.
|
|
2565
|
+
console.log(`[FileTide ~ Anchor Activity] ~ Received client ~ ${data.senderID} tiding.`);
|
|
2566
|
+
this.anchor.emitToTide(senderClient.tideID, "current-client-tiding", {
|
|
2387
2567
|
message: data.message
|
|
2388
2568
|
});
|
|
2389
2569
|
return;
|
|
2390
2570
|
} catch (error) {
|
|
2391
|
-
console.error(`[FileTide ~
|
|
2571
|
+
console.error(`[FileTide ~ Anchor Activity] ~ `, error);
|
|
2392
2572
|
return;
|
|
2393
2573
|
}
|
|
2394
2574
|
}
|
|
@@ -2415,4 +2595,4 @@ function _getTidalyticsRangeFetcher(interval, rangeMode, start, end) {
|
|
|
2415
2595
|
};
|
|
2416
2596
|
}
|
|
2417
2597
|
;
|
|
2418
|
-
module.exports =
|
|
2598
|
+
module.exports = FileTideAnchor;
|