mirror of
https://github.com/SrIzan10/helium.git
synced 2026-06-06 00:56:58 +00:00
chore: use peerjs stuff now
This commit is contained in:
94
README.md
94
README.md
@@ -1,93 +1,3 @@
|
||||
# Helium
|
||||
# helium
|
||||
|
||||
Effortless screensharing powered by WebRTC.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### TURN Server Setup
|
||||
|
||||
To enable connections through restrictive NATs, you need a TURN server. We use [Metered's Open Relay](https://www.metered.ca/tools/openrelay/) which provides 50GB/month free.
|
||||
|
||||
1. Sign up for a free account at https://dashboard.metered.ca/signup
|
||||
2. Create a new app (you'll get an app name like `yourapp.metered.live`)
|
||||
3. Copy your API key from the dashboard
|
||||
|
||||
4. Fill in your credentials in `.env`:
|
||||
|
||||
```bash
|
||||
METERED_APP_NAME=yourapp
|
||||
METERED_API_KEY=your_api_key_here
|
||||
REDIS_URL=redis://localhost:6379
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
||||
Make sure to install dependencies:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm install
|
||||
|
||||
# pnpm
|
||||
pnpm install
|
||||
|
||||
# yarn
|
||||
yarn install
|
||||
|
||||
# bun
|
||||
bun install
|
||||
```
|
||||
|
||||
## Development Server
|
||||
|
||||
Start the development server on `http://localhost:3000`:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm run dev
|
||||
|
||||
# pnpm
|
||||
pnpm dev
|
||||
|
||||
# yarn
|
||||
yarn dev
|
||||
|
||||
# bun
|
||||
bun run dev
|
||||
```
|
||||
|
||||
## Production
|
||||
|
||||
Build the application for production:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm run build
|
||||
|
||||
# pnpm
|
||||
pnpm build
|
||||
|
||||
# yarn
|
||||
yarn build
|
||||
|
||||
# bun
|
||||
bun run build
|
||||
```
|
||||
|
||||
Locally preview production build:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm run preview
|
||||
|
||||
# pnpm
|
||||
pnpm preview
|
||||
|
||||
# yarn
|
||||
yarn preview
|
||||
|
||||
# bun
|
||||
bun run preview
|
||||
```
|
||||
|
||||
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
|
||||
effortless webrtc screensharing
|
||||
@@ -20,20 +20,12 @@ const { send } = useWebSocket(wsUrl, {
|
||||
toast.success('stream joined successfully')
|
||||
}
|
||||
if (message.event === 'offer') {
|
||||
let iceServers: RTCIceServer[] = [
|
||||
{ urls: 'stun:stun.l.google.com:19302' },
|
||||
{ urls: 'stun:stun1.l.google.com:19302' },
|
||||
];
|
||||
|
||||
try {
|
||||
const turnCredentials = await $fetch('/api/turn/credentials');
|
||||
iceServers = turnCredentials as RTCIceServer[];
|
||||
} catch (error) {
|
||||
console.warn('Failed to fetch TURN credentials, using STUN only:', error);
|
||||
}
|
||||
|
||||
const peerConnection = new RTCPeerConnection({
|
||||
iceServers,
|
||||
iceServers: [
|
||||
{ urls: 'stun:stun.l.google.com:19302' },
|
||||
{ urls: 'stun:stun1.l.google.com:19302' },
|
||||
{ urls: "turn:0.peerjs.com:3478", username: "peerjs", credential: "peerjsp" },
|
||||
],
|
||||
iceCandidatePoolSize: 10
|
||||
});
|
||||
viewerStore.setPeerConnection(peerConnection);
|
||||
|
||||
@@ -23,20 +23,12 @@ const { send } = useWebSocket(wsUrl, {
|
||||
}
|
||||
|
||||
if (message.event === 'viewer-joined') {
|
||||
let iceServers: RTCIceServer[] = [
|
||||
{ urls: 'stun:stun.l.google.com:19302' },
|
||||
{ urls: 'stun:stun1.l.google.com:19302' },
|
||||
];
|
||||
|
||||
try {
|
||||
const turnCredentials = await $fetch('/api/turn/credentials');
|
||||
iceServers = turnCredentials as RTCIceServer[];
|
||||
} catch (error) {
|
||||
console.warn('Failed to fetch TURN credentials, using STUN only:', error);
|
||||
}
|
||||
|
||||
const peerConnection = new RTCPeerConnection({
|
||||
iceServers,
|
||||
iceServers: [
|
||||
{ urls: 'stun:stun.l.google.com:19302' },
|
||||
{ urls: 'stun:stun1.l.google.com:19302' },
|
||||
{ urls: "turn:0.peerjs.com:3478", username: "peerjs", credential: "peerjsp" },
|
||||
],
|
||||
iceCandidatePoolSize: 10
|
||||
});
|
||||
streamerStore.addPeerConnection(message.viewerId, peerConnection)
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const apiKey = process.env.METERED_API_KEY || '';
|
||||
const appName = process.env.METERED_APP_NAME || '';
|
||||
|
||||
if (!apiKey || !appName) {
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: 'TURN server not configured.'
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await $fetch(
|
||||
`https://${appName}.metered.live/api/v1/turn/credentials?apiKey=${apiKey}`
|
||||
);
|
||||
|
||||
return response;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch TURN credentials:', error);
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
message: 'Failed to fetch TURN credentials'
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user