-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
Can this module be used to connect more than 2 peers? #7
Comments
Great news! and one last question about this, by having a full-mesh topology does it makes each peer to load 5 times slower, or its up to me to make it fast and keep a low internet useage? Sorry for bad english |
I did some experiments in the past, and once the number of participants starts growing it becomes (much) more effective to distribute data between producer and consumers in a tree based fashion -- instead of using a mesh network. Obvious drawback of this approach is that it breaks the P2P serverless architecture, as you need an MCU type of server in the backend to create this tree-based overlay network. My prototype was based on the Erizo project, which I had to extend to glue multiple servers together into an overlay tree. |
When extending the example in the readme to use 3 peers, a |
No, you need to create a peer object for each connection. Like this: Peer 1// These are peer1's connections to peer2 and peer3
var peer2 = new SimplePeer({ initiator: true })
var peer3 = new SimplePeer({ initiator: true })
peer2.on('signal', function (data) {
// send this signaling data to peer2 somehow
})
peer2.on('ready', function () {
peer2.send('hi peer2, this is peer1')
})
peer2.on('message', function (data) {
console.log('got a message from peer2: ' + data)
})
peer3.on('signal', function (data) {
// send this signaling data to peer3 somehow
})
peer3.on('ready', function () {
peer3.send('hi peer3, this is peer1')
})
peer3.on('message', function (data) {
console.log('got a message from peer3: ' + data)
}) Peer 2// These are peer2's connections to peer1 and peer3
var peer1 = new SimplePeer()
var peer3 = new SimplePeer({ initiator: true })
peer1.on('signal', function (data) {
// send this signaling data to peer1 somehow
})
peer1.on('ready', function () {
peer1.send('hi peer1, this is peer2')
})
peer1.on('message', function (data) {
console.log('got a message from peer1: ' + data)
})
peer3.on('signal', function (data) {
// send this signaling data to peer3 somehow
})
peer3.on('ready', function () {
peer3.send('hi peer3, this is peer2')
})
peer3.on('message', function (data) {
console.log('got a message from peer3: ' + data)
}) Peer 3// These are peer3's connections to peer1 and peer2
var peer1 = new SimplePeer()
var peer2 = new SimplePeer()
peer1.on('signal', function (data) {
// send this signaling data to peer1 somehow
})
peer1.on('ready', function () {
peer1.send('hi peer1, this is peer3')
})
peer1.on('message', function (data) {
console.log('got a message from peer1: ' + data)
})
peer2.on('signal', function (data) {
// send this signaling data to peer2 somehow
})
peer2.on('ready', function () {
peer2.send('hi peer2, this is peer3')
})
peer2.on('message', function (data) {
console.log('got a message from peer2: ' + data)
}) |
Ah I see. That makes more sense. Thanks. |
Is there a way to connect more than 2 browsers together and have a 5 member peer2peer "call"?
The text was updated successfully, but these errors were encountered: