-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move example app into a demo folder * Move example app into a demo folder * rpc example * most of it * all the code * remove excess code * sample * almost working * close... * close... * demo is working * exfixes * cleanup * fmt * fmt * fmt * README * wip * cleanup * wip * fix tests * fixes * fmt * disconncect * dots * fmt * fix * Create beige-brooms-add.md * fix * fixes * comments * cleanups * clean * fixes * typo * Comment * fixes * Fix test * ts * fmt * private * better test * fmt * some fixes * no p on ack * fmt * ensure full connection * fmt * Change to use identities * fix * fmt * fix * semver * fmt * v * remove semver package * Move data packet into lp * rpc * simplify * fmt
- Loading branch information
Showing
21 changed files
with
3,561 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"livekit-client": minor | ||
--- | ||
|
||
RPC implementation |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,3 +112,5 @@ docs/ | |
pkg/ | ||
bin/ | ||
examples/**/build/ | ||
|
||
.env.local |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# RPC Demo | ||
|
||
A working multi-participant live demo of the LiveKit RPC feature. | ||
|
||
## Running the Demo | ||
|
||
1. Create `.env.local` with `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET`, and `LIVEKIT_URL` | ||
1. Install dependencies: `pnpm install` | ||
2. Start server: `pnpm dev` | ||
3. Open browser to local URL (typically http://localhost:5173) | ||
4. Press the button to watch the demo run | ||
|
||
For more detailed information on using RPC with LiveKit, refer to the [main README](../../README.md#rpc). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import dotenv from 'dotenv'; | ||
import express from 'express'; | ||
import type { Express } from 'express'; | ||
import { AccessToken } from 'livekit-server-sdk'; | ||
|
||
dotenv.config({ path: '.env.local' }); | ||
|
||
const LIVEKIT_API_KEY = process.env.LIVEKIT_API_KEY; | ||
const LIVEKIT_API_SECRET = process.env.LIVEKIT_API_SECRET; | ||
const LIVEKIT_URL = process.env.LIVEKIT_URL; | ||
|
||
const app = express(); | ||
app.use(express.json()); | ||
|
||
app.post('/api/get-token', async (req, res) => { | ||
const { identity, roomName } = req.body; | ||
|
||
if (!LIVEKIT_API_KEY || !LIVEKIT_API_SECRET) { | ||
res.status(500).json({ error: 'Server misconfigured' }); | ||
return; | ||
} | ||
|
||
const token = new AccessToken(LIVEKIT_API_KEY, LIVEKIT_API_SECRET, { | ||
identity, | ||
}); | ||
token.addGrant({ | ||
room: roomName, | ||
roomJoin: true, | ||
canPublish: true, | ||
canSubscribe: true, | ||
}); | ||
|
||
res.json({ | ||
token: await token.toJwt(), | ||
url: LIVEKIT_URL, | ||
}); | ||
}); | ||
|
||
export const handler: Express = app; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>LiveKit RPC Demo</title> | ||
<link rel="stylesheet" href="./styles.css" /> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>LiveKit RPC Demo</h1> | ||
<div id="log-area"> | ||
<textarea id="log" rows="15" readonly></textarea> | ||
</div> | ||
<button id="run-demo" class="btn">Run Demo</button> | ||
</div> | ||
<script type="module" src="./rpc-demo.ts"></script> | ||
</body> | ||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "livekit-rpc-example", | ||
"version": "1.0.0", | ||
"description": "Example of using LiveKit RPC", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc && vite build", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"cors": "^2.8.5", | ||
"dotenv": "^16.4.5", | ||
"express": "^4.21.1", | ||
"livekit-server-sdk": "^2.7.0", | ||
"vite": "^3.2.7", | ||
"vite-plugin-mix": "^0.4.0" | ||
}, | ||
"devDependencies": { | ||
"@types/cors": "^2.8.17", | ||
"@types/express": "^5.0.0", | ||
"concurrently": "^8.2.0", | ||
"tsx": "^4.7.0", | ||
"typescript": "^5.4.5" | ||
} | ||
} |
Oops, something went wrong.