mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-10 10:53:24 +00:00
- Rename create() → offer() to align with WebRTC offer creation - Rename connect() → answer() to align with WebRTC answer handling - Update README with new method names and examples - Version 0.3.3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
113 lines
2.7 KiB
Markdown
113 lines
2.7 KiB
Markdown
# Rondevu
|
|
|
|
🎯 **Simple WebRTC peer signaling**
|
|
|
|
Connect peers directly by ID with automatic WebRTC negotiation.
|
|
|
|
**Related repositories:**
|
|
- [rondevu-server](https://github.com/xtr-dev/rondevu-server) - HTTP signaling server
|
|
- [rondevu-demo](https://github.com/xtr-dev/rondevu-demo) - Interactive demo
|
|
|
|
---
|
|
|
|
## @xtr-dev/rondevu-client
|
|
|
|
[](https://www.npmjs.com/package/@xtr-dev/rondevu-client)
|
|
|
|
TypeScript client library for Rondevu peer signaling and WebRTC connection management. Handles automatic signaling, ICE candidate exchange, and connection establishment.
|
|
|
|
### Install
|
|
|
|
```bash
|
|
npm install @xtr-dev/rondevu-client
|
|
```
|
|
|
|
### Usage
|
|
|
|
#### Browser
|
|
|
|
```typescript
|
|
import { Rondevu } from '@xtr-dev/rondevu-client';
|
|
|
|
const rdv = new Rondevu({
|
|
baseUrl: 'https://api.ronde.vu',
|
|
rtcConfig: {
|
|
iceServers: [
|
|
{ urls: 'stun:stun.l.google.com:19302' },
|
|
{ urls: 'stun:stun1.l.google.com:19302' }
|
|
]
|
|
}
|
|
});
|
|
|
|
// Create an offer with custom ID
|
|
const connection = await rdv.offer('my-room-123');
|
|
|
|
// Or answer an existing offer
|
|
const connection = await rdv.answer('my-room-123');
|
|
|
|
// Use data channels
|
|
connection.on('connect', () => {
|
|
const channel = connection.dataChannel('chat');
|
|
channel.send('Hello!');
|
|
});
|
|
|
|
connection.on('datachannel', (channel) => {
|
|
if (channel.label === 'chat') {
|
|
channel.onmessage = (event) => {
|
|
console.log('Received:', event.data);
|
|
};
|
|
}
|
|
});
|
|
```
|
|
|
|
#### Node.js
|
|
|
|
```typescript
|
|
import { Rondevu } from '@xtr-dev/rondevu-client';
|
|
import wrtc from '@roamhq/wrtc';
|
|
import fetch from 'node-fetch';
|
|
|
|
const rdv = new Rondevu({
|
|
baseUrl: 'https://api.ronde.vu',
|
|
fetch: fetch as any,
|
|
wrtc: {
|
|
RTCPeerConnection: wrtc.RTCPeerConnection,
|
|
RTCSessionDescription: wrtc.RTCSessionDescription,
|
|
RTCIceCandidate: wrtc.RTCIceCandidate,
|
|
}
|
|
});
|
|
|
|
const connection = await rdv.offer('my-room-123');
|
|
|
|
connection.on('connect', () => {
|
|
const channel = connection.dataChannel('chat');
|
|
channel.send('Hello from Node.js!');
|
|
});
|
|
```
|
|
|
|
### API
|
|
|
|
**Main Methods:**
|
|
- `rdv.offer(id)` - Create an offer with custom ID
|
|
- `rdv.answer(id)` - Answer an existing offer by ID
|
|
|
|
**Connection Events:**
|
|
- `connect` - Connection established
|
|
- `disconnect` - Connection closed
|
|
- `error` - Connection error
|
|
- `datachannel` - New data channel received
|
|
- `stream` - Media stream received
|
|
|
|
**Connection Methods:**
|
|
- `connection.dataChannel(label)` - Get or create data channel
|
|
- `connection.addStream(stream)` - Add media stream
|
|
- `connection.close()` - Close connection
|
|
|
|
### Version Compatibility
|
|
|
|
The client automatically checks server compatibility via the `/health` endpoint. If the server version is incompatible, an error will be thrown during initialization.
|
|
|
|
### License
|
|
|
|
MIT
|