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

Peer network #6

@callumacrae

Description

@callumacrae

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions