@mega-yfue/eufy-sdk 0.4.0-beta.18 → 0.4.0-beta.19
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 +12 -9
- package/dist/index.js.map +2 -2
- package/dist/transport/p2p/p2p-session.d.ts +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15341,8 +15341,8 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
15341
15341
|
audioStalled = false;
|
|
15342
15342
|
audioRetransmitTimer;
|
|
15343
15343
|
lastPongData;
|
|
15344
|
-
/** When
|
|
15345
|
-
|
|
15344
|
+
/** When the selected peer last answered outbound P2P traffic on this connection. */
|
|
15345
|
+
lastPeerAt;
|
|
15346
15346
|
/** Whether the silence has already been stated, so it is traced once per connection rather than per read. */
|
|
15347
15347
|
pathStaleTraced = false;
|
|
15348
15348
|
lookupTimer;
|
|
@@ -15411,17 +15411,17 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
15411
15411
|
/**
|
|
15412
15412
|
* How long this connection's path has been silent, or nothing where it has never answered.
|
|
15413
15413
|
*
|
|
15414
|
-
*
|
|
15415
|
-
*
|
|
15414
|
+
* PONG and ACK from the selected peer prove the path answers outbound traffic. `undefined` means no such reply
|
|
15415
|
+
* has arrived since connection, so silence alone does not establish a stale path.
|
|
15416
15416
|
*/
|
|
15417
15417
|
get pathSilentMs() {
|
|
15418
|
-
return this.
|
|
15418
|
+
return this.lastPeerAt === void 0 ? void 0 : Date.now() - this.lastPeerAt;
|
|
15419
15419
|
}
|
|
15420
15420
|
/**
|
|
15421
15421
|
* Whether this path can still be committed to, on the evidence the heartbeat gives.
|
|
15422
15422
|
*
|
|
15423
|
-
* False where
|
|
15424
|
-
* not known to be dead, so it answers true.
|
|
15423
|
+
* False where selected-peer replies arrived and then stopped for {@link PATH_SILENCE_MS}. A connection with
|
|
15424
|
+
* no post-connect reply is not known to be dead, so it answers true.
|
|
15425
15425
|
*
|
|
15426
15426
|
* Traces the silence once per connection, on the read that first observes it.
|
|
15427
15427
|
*/
|
|
@@ -15806,6 +15806,11 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
15806
15806
|
onMessage(msg, rinfo, socket = this.socket) {
|
|
15807
15807
|
if (!socket)
|
|
15808
15808
|
return;
|
|
15809
|
+
const fromConnectedPeer = this.connected && this.connectAddress?.host === rinfo.address && this.connectAddress.port === rinfo.port;
|
|
15810
|
+
if (fromConnectedPeer && (hasHeader(msg, ResponseMessageType.PONG) || hasHeader(msg, ResponseMessageType.ACK))) {
|
|
15811
|
+
this.lastPeerAt = Date.now();
|
|
15812
|
+
this.pathStaleTraced = false;
|
|
15813
|
+
}
|
|
15809
15814
|
if (!hasHeader(msg, ResponseMessageType.DATA)) {
|
|
15810
15815
|
this.logger.debug(`[p2p] ${this.cfg.stationSn} <<< ${rinfo.address}:${rinfo.port} header=${msg.subarray(0, 2).toString("hex")} len=${msg.length}`);
|
|
15811
15816
|
}
|
|
@@ -15823,8 +15828,6 @@ var P2PSession = class _P2PSession extends EventEmitter2 {
|
|
|
15823
15828
|
this.onConnected({ host: rinfo.address, port: rinfo.port }, socket);
|
|
15824
15829
|
} else if (hasHeader(msg, ResponseMessageType.PONG)) {
|
|
15825
15830
|
this.lastPongData = msg.length > 4 ? msg.subarray(4) : void 0;
|
|
15826
|
-
this.lastPongAt = Date.now();
|
|
15827
|
-
this.pathStaleTraced = false;
|
|
15828
15831
|
} else if (hasHeader(msg, ResponseMessageType.PING)) {
|
|
15829
15832
|
this.send({ host: rinfo.address, port: rinfo.port }, RequestMessageType.PONG, void 0, socket);
|
|
15830
15833
|
} else if (hasHeader(msg, ResponseMessageType.ACK)) {
|