Skip to content
This repository has been archived by the owner on Jul 11, 2019. It is now read-only.

Peer network #6

Open
callumacrae opened this issue Nov 11, 2016 · 2 comments
Open

Peer network #6

callumacrae opened this issue Nov 11, 2016 · 2 comments

Comments

@callumacrae
Copy link

Hey!

I've been thinking about how to solve the problem of a peer-to-peer group chat between a significant number of users without overloading the network: if I'm in a room with 1000 people, I don't want my browser to open 999 connections.

If I'm understanding the code correctly, does friends just open a connection to every other peer like I just described?

friends-swarm/swarm.js

Lines 100 to 120 in 02bc0e1

sw.on('peer', function (p, id) {
var stream = log.replicate({live: true})
log.peers.push(p)
p.on('close', function () {
var i = log.peers.indexOf(p)
if (i > -1) log.peers.splice(i, 1)
})
swarm.emit('peer', p, name, id, stream)
stream.on('push', function () {
swarm.emit('push', name)
})
stream.on('pull', function () {
swarm.emit('pull', name)
})
p.pipe(stream).pipe(p)
})

This feels like it's going to be a super interesting problem to solve: have any of you thought about it before or know anything about the topic?

@Flet
Copy link
Member

Flet commented Nov 11, 2016

Its possible to pass maxPeers to limit the number of connections. Here is where friends does it.

maxPeers is an option exposed by webrtc-swarm.

👍

@callumacrae
Copy link
Author

What happens when the number of users exceeds 20?

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

No branches or pull requests

2 participants