Skip to content

Commit

Permalink
fix: improve resilience to conectivity issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelin committed Mar 2, 2020
1 parent b356e22 commit a70d921
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/store/pnp.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ const actions = {
*/
async [PNP_SERVICE_CONNECT] ({ state, commit, dispatch }) {
// if connection to pnp service already open, then nothing to do
if (peer && peer.open) return
if (peer && peer.open) { return }
// if in the middle of pnp server connection cycle, skip
if (state.pnpServiceConnectionStatus === PNP_SERVICE_CONNECTING) { return }
// Create own peer object with connection to shared PeerJS server
console.log('pnp client: creating peer')
// If we already have an assigned peerId, we will reuse it forever.
Expand All @@ -320,6 +322,8 @@ const actions = {
async [PNP_SERVICE_RECONNECT] ({ state, commit, dispatch }) {
// if connection to pnp service already open, then nothing to do
if (peer.open) return
// if in the middle of pnp server connection cycle, skip
if (state.pnpServiceConnectionStatus === PNP_SERVICE_CONNECTING) { return }
console.log('pnp client: reconnecting peer...')
// Workaround for peer.reconnect deleting previous id
if (!peer.id) {
Expand Down

0 comments on commit a70d921

Please sign in to comment.