mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-11 19:33:25 +00:00
feat: Replace RondevuConnection with RondevuPeer state machine
- Created type-safe EventEmitter with generics - Implemented state pattern for peer connection lifecycle - Added comprehensive timeout handling for all connection phases - Removed client-provided offer IDs (server generates hash-based IDs) - Replaced RondevuConnection with RondevuPeer throughout - Added states: idle, creating-offer, waiting-for-answer, answering, exchanging-ice, connected, failed, closed - Configurable timeouts: ICE gathering, waiting for answer, creating answer, ICE connection - Better error handling with 'failed' event and error details 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { RondevuAuth, Credentials, FetchFunction } from './auth.js';
|
||||
import { RondevuOffers } from './offers.js';
|
||||
import { RondevuConnection, ConnectionOptions } from './connection.js';
|
||||
import RondevuPeer from './peer.js';
|
||||
|
||||
export interface RondevuOptions {
|
||||
/**
|
||||
@@ -87,17 +87,17 @@ export class Rondevu {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new WebRTC connection (requires authentication)
|
||||
* This is a high-level helper that creates and manages WebRTC connections
|
||||
* Create a new WebRTC peer connection (requires authentication)
|
||||
* This is a high-level helper that creates and manages WebRTC connections with state management
|
||||
*
|
||||
* @param rtcConfig Optional RTCConfiguration for the peer connection
|
||||
* @returns RondevuConnection instance
|
||||
* @returns RondevuPeer instance
|
||||
*/
|
||||
createConnection(rtcConfig?: RTCConfiguration): RondevuConnection {
|
||||
createPeer(rtcConfig?: RTCConfiguration): RondevuPeer {
|
||||
if (!this._offers) {
|
||||
throw new Error('Not authenticated. Call register() first or provide credentials.');
|
||||
}
|
||||
|
||||
return new RondevuConnection(this._offers, rtcConfig);
|
||||
return new RondevuPeer(this._offers, rtcConfig);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user