@mega-yfue/eufy-sdk 0.5.0-beta.75 → 0.5.0-beta.77

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/index.js CHANGED
@@ -17841,15 +17841,17 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
17841
17841
  }
17842
17842
  this.emit("data", frame);
17843
17843
  }
17844
- send(addr, type, payload, socket = this.socket) {
17844
+ send(addr, type, payload, socket = this.socket, done) {
17845
17845
  if (!socket)
17846
17846
  return;
17847
17847
  const packet = frameMessage(type, payload);
17848
17848
  socket.send(packet, addr.port, addr.host, (err) => {
17849
17849
  if (err)
17850
17850
  this.logger.warn(`[p2p] send err ${addr.host}:${addr.port}`, err.message);
17851
+ done?.();
17851
17852
  });
17852
17853
  }
17854
+ /** Finish the END send on the current socket before closing it; send completion is not a peer ACK. */
17853
17855
  async close() {
17854
17856
  if (this.closed)
17855
17857
  return;
@@ -17878,12 +17880,14 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
17878
17880
  this.liveStartRetransmitTimer = void 0;
17879
17881
  this.unackedLiveStarts.clear();
17880
17882
  this.resetInboundSequencing();
17881
- if (this.connectAddress)
17882
- this.send(this.connectAddress, RequestMessageType.END);
17883
+ const socket = this.socket;
17884
+ if (socket && this.connectAddress) {
17885
+ await new Promise((resolve) => this.send(this.connectAddress, RequestMessageType.END, void 0, socket, resolve));
17886
+ }
17883
17887
  await new Promise((resolve) => {
17884
- if (!this.socket)
17888
+ if (!socket)
17885
17889
  return resolve();
17886
- this.socket.close(() => resolve());
17890
+ socket.close(() => resolve());
17887
17891
  });
17888
17892
  this.socket = void 0;
17889
17893
  this.emit("close");