@trap_stevo/filetide-client 0.0.31 → 0.0.33

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.
@@ -162,7 +162,7 @@ class FileTideClient {
162
162
  console.log(this.applyGradient(message, "neutral"));
163
163
  }
164
164
  }
165
- broadcastClientOffline(fileMessager) {
165
+ broadcastClientOffline(fileMessager, forceBroadcast = false) {
166
166
  if (fileMessager && !this.clientDisconnected) {
167
167
  this.clientDisconnected = true;
168
168
  const transferStates = fileTide.getTidingTransferStates();
@@ -172,23 +172,35 @@ class FileTideClient {
172
172
  disconnectedDuringTransfer: transferStates.size > 0 ? true : false
173
173
  });
174
174
  FileTide.outputGradient(`[${this.deviceName}] Disconnected from the file net.`, ["#00C897", "#00E0FF"]);
175
+ return;
175
176
  }
177
+ if (!fileMessager || !forceBroadcast) {
178
+ return;
179
+ }
180
+ this.clientDisconnected = true;
181
+ const transferStates = fileTide.getTidingTransferStates();
182
+ fileMessager.clientTide.emitEvent(this.deviceName, "client-offline", {
183
+ clientID: this.deviceName,
184
+ connectionID: this.connectionID,
185
+ disconnectedDuringTransfer: transferStates.size > 0 ? true : false
186
+ });
187
+ FileTide.outputGradient(`[${this.deviceName}] Disconnected from the file net.`, ["#00C897", "#00E0FF"]);
176
188
  }
177
- async closeAllClients(onClientDisconnect, onCompletion) {
189
+ async closeAllClients(onBeforeClientDisconnect, onClientDisconnect, onCompletion) {
178
190
  await fileTide.stopAllMessagers(async (...data) => {
179
191
  this.broadcastClientOffline(this.fileMessagerInstance);
180
- if (typeof onClientDisconnect === "function") {
181
- onClientDisconnect(...data);
192
+ if (typeof onBeforeClientDisconnect === "function") {
193
+ await onBeforeClientDisconnect(...data);
182
194
  }
183
- }, onCompletion);
195
+ }, onClientDisconnect, onCompletion);
184
196
  }
185
- async closeClient(userID, onDisconnect, onCompletion) {
197
+ async closeClient(userID, onBeforeDisconnect, onDisconnect, onCompletion) {
186
198
  await fileTide.stopMessager(userID, async (...data) => {
187
199
  this.broadcastClientOffline(this.fileMessagerInstance);
188
- if (typeof onDisconnect === "function") {
189
- onDisconnect(...data);
200
+ if (typeof onBeforeDisconnect === "function") {
201
+ await onBeforeDisconnect(...data);
190
202
  }
191
- }, onCompletion);
203
+ }, onDisconnect, onCompletion);
192
204
  }
193
205
  startClient(clientOptions = {}, connectionOptions = {}, transportOptions = {
194
206
  parallelChunks: 3,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide-client",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "Seamless, real-time file transfers between devices with effortless connectivity. Allowing for powerful, instant, secure, and cross-platform file sharing, enabling efficient and reliable data transfers in any network environment.",
5
5
  "main": "dist/cjs/FileTideClient.js",
6
6
  "exports": {
@@ -37,7 +37,7 @@
37
37
  "author": "Steven Compton",
38
38
  "license": "See License in LICENSE.md",
39
39
  "dependencies": {
40
- "@trap_stevo/filetide": "^0.0.60",
40
+ "@trap_stevo/filetide": "^0.0.62",
41
41
  "@trap_stevo/iotide": "^0.0.43",
42
42
  "@trap_stevo/legendarybuilderpronodejs-utilities": "^1.0.43",
43
43
  "chalk": "^4.1.2",