Published
Edited
Nov 16, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Peer = (await require('peerjs')).peerjs.Peer
Insert cell
peer = {
const peer = new Peer(({
config: {'iceServers': [
{ url: 'stun:stun.l.google.com:19302' },
//{ url: 'turn:homeo@turn.bistri.com:80', credential: 'homeo' }
]}, /* Sample servers, please use appropriate ones */
debug: 3,
}));

peer.on('open', () => {
console.debug('Connection to signalling server established.')
mutable isOpen = true
mutable isDisconnected = false
})

peer.on('disconnected', () => {
console.debug('Lost connection to signalling server.')
mutable isOpen = false
mutable isDisconnected = true
})
peer.on('connection', (conn) => {
console.debug("Connected to: ", conn.peer)

if (mutable partner_id !== conn.peer) {
mutable partner_id = conn.peer
}
conn.on('data', function({data, from}){
mutable received_data = data
mutable partner_id = from
});
});

peer.on('error', (error) => {
console.error("ERROR: ", error)
})

return peer
}
Insert cell
Insert cell
conn = {
if (isOpen && remotePeerId) {
console.debug("Connecting to: ", remotePeerId)
return peer.connect(remotePeerId, {reliable: true})
}
return null
}
Insert cell
Insert cell
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