Last active
June 10, 2020 11:49
-
-
Save oed/8cdabbc75db2a544c46598d065fbc125 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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