Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify connection state. #41

Open
martinheidegger opened this issue May 21, 2018 · 1 comment
Open

Clarify connection state. #41

martinheidegger opened this issue May 21, 2018 · 1 comment

Comments

@martinheidegger
Copy link
Contributor

.join()-ing a swarm will execute the callback once the announcement to the bittorrent network went through. However, during the announcement-process peers are already added as they appear, making the network basically usable. To clarify the state I suggest the implementation of a "connection-state".

What I am thinking about looks something like this:

swarm.on('connection-state-change', state => {
  switch (state) {
     case 'disconnected': break; // Not connected
     case 'connecting': break; // Join called but no peer connected
     case 'connected-one-peer': break; // One peer is connected but not connected to wider network
     case 'connected-many-peer': break; // Connected to more than one peer
     case 'connected-wellknown-peer': break; // Connected to a well-known-peer - aka. the internet.
  }
})
swarm.connectionState; // Current state available as property
swarm.join(); // No callback ... necessary?!
@DennisSchwartz
Copy link

I would very much appreciate this as well! +1

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

No branches or pull requests

2 participants