Skip to content

Commit

Permalink
Can enter room via URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Lewis committed Oct 2, 2020
1 parent 5a48e80 commit 8b89b35
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Empty file added client/index.html
Empty file.
29 changes: 29 additions & 0 deletions client/room.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Build a Thing Video App</title>
</head>
<body>
<div id="publishers"></div>
<div id="subscribers"></div>

<script src="https://static.opentok.com/v2/js/opentok.min.js"></script>
<script>
const params = Object.fromEntries(new URLSearchParams(location.search))
fetch(`/api/session?room=${params.room}`)
.then(r => r.json())
.then(({ apiKey, sessionId, token }) => {
const session = OT.initSession(apiKey, sessionId)
const camera = OT.initPublisher('publishers', { mirror: false })
session.connect(token, () => {
session.publish(camera)
})
session.on('streamCreated', event => {
session.subscribe(event.stream, 'subscribers')
})
})
</script>
</body>
</html>
1 change: 1 addition & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[build]
functions = "functions"
publish = "client"
[[redirects]]
from = "/api/*"
to = "/.netlify/functions/:splat"
Expand Down

0 comments on commit 8b89b35

Please sign in to comment.