Published
Edited
Apr 2, 2021
4 stars
Insert cell
Insert cell
my_id = await (new Promise(resolve => peer.on('open', id => resolve(id)))) // Copy the id above (no quotes).
Insert cell
viewof their_id = html`<input/>` // Open a new tab, input the target instance's id and check the console.
Insert cell
Peer = (await require('peerjs')).peerjs.Peer
Insert cell
peer = new Peer(({
config: {'iceServers': [
{ url: 'stun:stun.stunprotocol.org' }, /* STUN server */
//{ url: 'turn:homeo@turn.bistri.com:80', credential: 'homeo' } /* TURN server */
]}
}))
Insert cell
{
if (!their_id) return
const c = peer.connect(their_id)
c.on('open', () => c.send('sent', 'test message'))
}
Insert cell
peer.on('connection', c => c.on('data', d => console.log('received', d)))
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more