Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

A few BUGFIXES and new tests to cover those scenarios + multiple signalling servers! #89

Closed

Conversation

michaelfakhri
Copy link
Contributor

@michaelfakhri michaelfakhri commented Jan 26, 2017

Continuing #54

A few mishaps and that branch is no longer merge-able, so I created this new and cleaner branch

Here is a summary of all the changes:

  • Variable maSelf was redirecting all dials to come back through the last added listener. This definitely does not make any sense, since the last added listener will most likely be another signalling server which will have a completely different multi-address. This means that the peer will never get the answer for the offer creating an error state on the server side and on the peer's side.

  • Closing the listener did not close the socket connection to the signalling server. This safe to do at the moment since each listener creates a new socket connection to be used.

  • Moved the close and getObservedAddr functions to be added only when the listen function is called since they do not make any sense if the listener is not listening.There is no multi-address to return or a listener to close if its not listening.

  • Fixed ss-leave event which did not pass the multi-address to the server

  • Fixed an issue where the listener was added with a function as the key to the listeners map/array

  • Moved adding the listener to the listeners array to occur only once its connected to the signalling server, otherwise its just have a bad listener that cannot actually dial anywhere

  • Part of this PR addresses Websocket stays connected even after webrtc-star listener is closed Websocket stays connected even after webrtc-star listener is closed #51

  • EDIT: This PR also adds support for handling multiple signalling servers
    Let me know if you need me to make any changes.

@michaelfakhri michaelfakhri changed the title A few BUGFIXES and new tests to cover those scenarios A few BUGFIXES and new tests to cover those scenarios + multiple signalling servers! Jan 26, 2017
@michaelfakhri
Copy link
Contributor Author

Everything's green!
Ready for review and merge

@@ -60,7 +58,11 @@ class WebRTCStar {
callback = callback ? once(callback) : noop

const intentId = (~~(Math.random() * 1e9)).toString(36) + Date.now()
const sioClient = this.listenersRefs[Object.keys(this.listenersRefs)[0]].io
const keys = Object.keys(this.listenersRefs)
.filter((key) => cleanUrlSIO(ma) === cleanUrlSIO(multiaddr(key)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation here looks a tad weird, might reconsider making it more readable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@daviddias
Copy link
Member

I plan to review this PR carefully this week. Apologies for the time waiting ETOOMANYPRS :D

sigS2 = server
console.log('signalling 2 on:', server.info.uri)
cb()
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two functions could be one, taking the options as a parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
function second (cb) {
sigS2.stop(() => cb())
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be simpler

async.forEach([first, second], (server) => server.stop(cb), done)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@daviddias
Copy link
Member

Hi @michaelfakhri, would love to merge this so that we can actually have more than one signalling rendezvous point (will be super useful when we replace the server with a libp2p node //cc @lgierth )

Are you up to update this PR (rebase master onto it) ?

@daviddias
Copy link
Member

Ping @michaelfakhri :)

@vasco-santos
Copy link
Member

As we completely refactored this module and this PR is not active for a long time I will close it

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Websocket stays connected even after webrtc-star listener is closed
4 participants