Ensure connection with peers after going offline (#297)

* Redial relay node on failure and after going offline

* Redial only relay node if not connected

* Refactor and rename methods

* Only close existing connection to relay node

* Hearbeat check only for relay node

* Refactor startHeartbeatCheck method
This commit is contained in:
2023-01-19 15:01:40 +05:30
committed by GitHub
parent 9d38306fe9
commit b07e288756
3 changed files with 129 additions and 21 deletions
+4
View File
@@ -14,6 +14,7 @@ declare global {
interface Window {
broadcast: (message: string) => void;
flood: (message: string) => void;
peer: Peer;
}
}
@@ -28,6 +29,9 @@ function App() {
return
}
// For debugging
window.peer = peer;
// Subscribe to messages from remote peers
const unsubscribeMessage = peer.subscribeMessage((peerId, message) => {
console.log(`${peerId.toString()} > ${message}`)