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

room.broadcast only sends messages to itself not other peers. #66

Open
niinpatel opened this issue Mar 10, 2019 · 1 comment
Open

room.broadcast only sends messages to itself not other peers. #66

niinpatel opened this issue Mar 10, 2019 · 1 comment

Comments

@niinpatel
Copy link

niinpatel commented Mar 10, 2019

Problem:

I was trying to follow along this tutorial on ipfs-pubsub-room.

The problem is when I do room.broadcast('some message').

Other peers do not get the message but the sender gets its own message.

Here's the code I wrote:

const IPFS = require('ipfs')
const Room = require('ipfs-pubsub-room')

const ipfsRepo = require('./utils/ipfs-repo')

const ipfs = new IPFS({
  repo: ipfsRepo(),
  EXPERIMENTAL: {
    pubsub: true
  },
  config: {
    Addresses: {
      Swarm: [
        '/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star'
      ]
    }
  }
})

ipfs.once('ready', () => {
  ipfs.id((err, info) => {
    if (err) throw err
    console.log('IPFS node ready with address,', info.id)
  })

  const room = Room(ipfs, 'cPsnqzpAslkNCgGw6Tid')

  room.on('peer joined', (peer) => {
    console.log('peer ', peer, 'joined')
  })

  room.on('peer left', (peer) => {
    console.log('peer', peer, 'left')
  })

  room.on('message', (message) => {
    console.log('message from', message.from, 'contents:', message.data.toString())
  })

  setTimeout(() => room.broadcast('hey everyone!'), 2000)
})

Dependencies List:

"dependencies": {
    "ipfs": "^0.34.4",
    "ipfs-pubsub-room": "^1.4.1"
  }
@niinpatel niinpatel changed the title room.broadcasts only sends messages to itself not other peers. room.broadcast only sends messages to itself not other peers. Mar 10, 2019
@ahfriedman
Copy link

I'm having the same issue. Have you found a solution?

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