@trap_stevo/filetide-client 0.0.30 → 0.0.32

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,7 +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"]);
188
+ }
189
+ async closeAllClients(onBeforeClientDisconnect, onClientDisconnect, onCompletion) {
190
+ await fileTide.stopAllMessagers(async (...data) => {
191
+ this.broadcastClientOffline(this.fileMessagerInstance);
192
+ if (typeof onBeforeClientDisconnect === "function") {
193
+ await onBeforeClientDisconnect(...data);
194
+ }
195
+ }, onClientDisconnect, onCompletion);
196
+ }
197
+ async closeClient(userID, onBeforeDisconnect, onDisconnect, onCompletion) {
198
+ await fileTide.stopMessager(userID, async (...data) => {
199
+ this.broadcastClientOffline(this.fileMessagerInstance);
200
+ if (typeof onBeforeDisconnect === "function") {
201
+ await onBeforeDisconnect(...data);
202
+ }
203
+ }, onDisconnect, onCompletion);
176
204
  }
177
205
  startClient(clientOptions = {}, connectionOptions = {}, transportOptions = {
178
206
  parallelChunks: 3,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trap_stevo/filetide-client",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
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.59",
40
+ "@trap_stevo/filetide": "^0.0.61",
41
41
  "@trap_stevo/iotide": "^0.0.43",
42
42
  "@trap_stevo/legendarybuilderpronodejs-utilities": "^1.0.43",
43
43
  "chalk": "^4.1.2",