Platform
Resources
Pricing
Sign in
Get started
Edward Misback
Live programming @ University of Washington
Workspace
Fork
Published
By
Edward Misback
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
1
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.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
my_id
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
their_id
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Peer
Show 1 comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
peer
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML