@trap_stevo/filetide 0.0.0 → 0.0.2
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
|
@@ -10,14 +10,13 @@ const {
|
|
|
10
10
|
class FileMessager {
|
|
11
11
|
constructor(options = {}) {
|
|
12
12
|
const serverOptions = FileMessagerConfigManager.getServerOptions(options);
|
|
13
|
-
this.
|
|
13
|
+
this.fileNet = new IoTide(serverOptions.port, serverOptions, true, this.onConnect.bind(this), this.onDisconnect.bind(this));
|
|
14
14
|
this.onlineClients = new Map();
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
onConnect(socket) {
|
|
18
18
|
console.log(`Client connected: ${socket.id}`);
|
|
19
19
|
this.onlineClients.set(socket.id, socket);
|
|
20
|
-
socket.on("client-to-client-transfer", this.handleClientToClientTransfer.bind(this));
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
22
|
onDisconnect(connectionRes, socket) {
|
|
@@ -26,9 +25,10 @@ class FileMessager {
|
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
28
27
|
start() {
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
28
|
+
this.fileNet.on("transfer-start", this.handleFileTransferStart.bind(this));
|
|
29
|
+
this.fileNet.on("transfer-progress", this.handleFileTransferProgress.bind(this));
|
|
30
|
+
this.fileNet.on("transfer-complete", this.handleFileTransferComplete.bind(this));
|
|
31
|
+
this.fileNet.on("client-to-client-transfer", this.handleClientToClientTransfer.bind(this));
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -19,7 +19,7 @@ class FileMessagerClient {
|
|
|
19
19
|
this.clientTide.createIO(clientID, clientOptions.url, {
|
|
20
20
|
transports: ["websocket"]
|
|
21
21
|
});
|
|
22
|
-
console.log(`[
|
|
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,37 +27,37 @@ class FileMessagerClient {
|
|
|
27
27
|
url: this.clientOptions.url
|
|
28
28
|
});
|
|
29
29
|
this.clientTide.joinChannel(socketName, roomName, userID, () => {
|
|
30
|
-
console.log(`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
36
|
sendFile(recipientId, fileName, fileData, path = process.cwd()) {
|
|
37
|
-
this.clientTide.emitEvent("client-to-client-transfer", {
|
|
37
|
+
this.clientTide.emitEvent(recipientId, "client-to-client-transfer", {
|
|
38
38
|
recipientId,
|
|
39
39
|
fileName,
|
|
40
40
|
fileData,
|
|
41
41
|
path
|
|
42
42
|
});
|
|
43
|
-
console.log(`File ${fileName} sent to client ${recipientId}.`);
|
|
43
|
+
console.log(`[FileTide ~ File Messager] ~ File ${fileName} sent to client ${recipientId}.`);
|
|
44
44
|
}
|
|
45
45
|
onFileChunkReceived(userID) {
|
|
46
46
|
this.clientTide.onEvent(userID, "transfer-progress", data => {
|
|
47
|
-
console.log(`Receiving file chunk for user ${userID}: `, data.fileChunk);
|
|
48
|
-
console.log("Progress: ", data.progress);
|
|
47
|
+
console.log(`[FileTide ~ File Messager] ~ Receiving file chunk for user ${userID}: `, data.fileChunk);
|
|
48
|
+
console.log("[FileTide ~ File Messager] ~ Progress: ", data.progress);
|
|
49
49
|
FileUtilityManager.saveChunk(userID, data.fileChunk, data.path, data.name);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
onFileTransferComplete(userID) {
|
|
53
53
|
this.clientTide.onEvent(userID, "transfer-complete", data => {
|
|
54
|
-
console.log(`File transfer completed for user ${userID}.`);
|
|
54
|
+
console.log(`[FileTide ~ File Messager] ~ File transfer completed for user ${userID}.`);
|
|
55
55
|
FileUtilityManager.assembleFile(userID);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
handleIncomingFile(userID) {
|
|
59
59
|
this.clientTide.onEvent(userID, "incoming-file", data => {
|
|
60
|
-
console.log(`Received file for user ${userID}: ${data.fileName}.`);
|
|
60
|
+
console.log(`[FileTide ~ File Messager] ~ Received file for user ${userID}: ${data.fileName}.`);
|
|
61
61
|
FileUtilityManager.saveFile(data.fileName, data.fileData, data.path, data.name);
|
|
62
62
|
});
|
|
63
63
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trap_stevo/filetide",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
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": {
|