Skip to content

Commit

Permalink
feat: 応答が無くなったPeerへの自動再接続
Browse files Browse the repository at this point in the history
ネットワーク変化など何らかの要因によってPeerが応答しなくなった際に自動再接続を試みる.
  • Loading branch information
TK11235 committed Aug 1, 2023
1 parent 7a16edf commit 56ab91f
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,10 @@ export class SkyWayConnection implements Connection {
this.closeDataConnection(conn);
});
conn.on('stats', () => {
if (conn.peer.session.health < 0.2) {
if (conn.peer.session.health < 0.35 || (conn.peer.session.grade < 1 && conn.peer.session.health < 0.7)) {
console.log(`reconnecting... ${conn.peer.peerId}`);
this.closeDataConnection(conn);
this.connect(conn.peer);
}
});
}
Expand Down

0 comments on commit 56ab91f

Please sign in to comment.