mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-10 02:43:25 +00:00
Add Node.js support via WebRTC polyfill injection
- Added WebRTCPolyfill interface for injecting WebRTC implementations - Added wrtc option to RondevuOptions and RondevuConnectionParams - Updated Rondevu and RondevuConnection to use injected APIs - Added helpful error message when RTCPeerConnection is not available - Updated README with Node.js usage examples - Version bumped to 0.3.0 Fixes: RTCPeerConnection not defined error in Node.js 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
42
README.md
42
README.md
@@ -24,10 +24,12 @@ npm install @xtr-dev/rondevu-client
|
||||
|
||||
### Usage
|
||||
|
||||
#### Browser
|
||||
|
||||
```typescript
|
||||
import { Rondevu } from '@xtr-dev/rondevu-client';
|
||||
|
||||
const rdv = new Rondevu({
|
||||
const rdv = new Rondevu({
|
||||
baseUrl: 'https://server.com',
|
||||
rtcConfig: {
|
||||
iceServers: [
|
||||
@@ -56,6 +58,44 @@ conn.on('connect', () => {
|
||||
});
|
||||
```
|
||||
|
||||
#### Node.js
|
||||
|
||||
In Node.js, you need to provide a WebRTC polyfill since WebRTC APIs are not natively available:
|
||||
|
||||
```bash
|
||||
npm install @roamhq/wrtc
|
||||
# or
|
||||
npm install wrtc
|
||||
```
|
||||
|
||||
```typescript
|
||||
import { Rondevu } from '@xtr-dev/rondevu-client';
|
||||
import wrtc from '@roamhq/wrtc';
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
const rdv = new Rondevu({
|
||||
baseUrl: 'https://server.com',
|
||||
fetch: fetch as any,
|
||||
wrtc: {
|
||||
RTCPeerConnection: wrtc.RTCPeerConnection,
|
||||
RTCSessionDescription: wrtc.RTCSessionDescription,
|
||||
RTCIceCandidate: wrtc.RTCIceCandidate,
|
||||
},
|
||||
rtcConfig: {
|
||||
iceServers: [
|
||||
{ urls: 'stun:stun.l.google.com:19302' }
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
// Rest is the same as browser usage
|
||||
const conn = await rdv.join('room');
|
||||
conn.on('connect', () => {
|
||||
const channel = conn.dataChannel('chat');
|
||||
channel.send('Hello from Node.js!');
|
||||
});
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
**Main Methods:**
|
||||
|
||||
Reference in New Issue
Block a user