Skip to content

Instantly share code, notes, and snippets.

@oed
Last active June 10, 2020 11:49
Show Gist options
  • Select an option

  • Save oed/8cdabbc75db2a544c46598d065fbc125 to your computer and use it in GitHub Desktop.

Select an option

Save oed/8cdabbc75db2a544c46598d065fbc125 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<title>Webrtc Demo</title>
<script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.js"></script>
</head>
<body>
<script type="text/javascript">
const opts = {
preload: { enabled: false },
repo: Math.random().toString(36).substring(7),
config: {
Bootstrap: [],
Addresses: {
Swarm: ['/dns4/p2p.3box.io/tcp/9091/wss/p2p-webrtc-star/']
}
}
}
Ipfs.create(opts).then(ipfs => {
window.ipfs = ipfs
ipfs.libp2p.on('peer:discovery', (peer) => {
console.log('discovered', peer)
})
ipfs.libp2p.on('peer:connect', async (peer) => {
console.log('connected', peer)
ipfs.swarm.peers().then(peers => console.log('current peers connected: ', peers))
})
})
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment