From 9b5b35ef7d0ef4f0d2177c1652dc5e7b011c5c95 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Fri, 12 Dec 2025 22:13:13 +0100 Subject: [PATCH] Update to use Rondevu.connect() and ICE server presets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace new Rondevu() + initialize() with Rondevu.connect() - Use rtcPreset state variable for iceServers option - Update NODE_HOST_GUIDE.md examples to use presets and new API 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- NODE_HOST_GUIDE.md | 25 +++++++++++++------------ src/App.jsx | 8 ++++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/NODE_HOST_GUIDE.md b/NODE_HOST_GUIDE.md index ffd685d..1566ec2 100644 --- a/NODE_HOST_GUIDE.md +++ b/NODE_HOST_GUIDE.md @@ -87,7 +87,8 @@ const API_URL = 'https://api.ronde.vu' const USERNAME = 'chatbot' // Your service username const SERVICE = 'chat:2.0.0' // Service name (username will be auto-appended) -// TURN server configuration for NAT traversal +// TURN server configuration for manual RTCPeerConnection setup +// Note: If using automatic offer management, configure via Rondevu.connect() iceServers option const RTC_CONFIG = { iceServers: [ { urls: 'stun:stun.l.google.com:19302' }, @@ -106,16 +107,16 @@ async function main() { console.log('🤖 Starting Chat Bot Service') console.log('='.repeat(50)) - // 1. Initialize Rondevu with Node crypto adapter - console.log('1. Initializing Rondevu client...') - const rondevu = new Rondevu({ + // 1. Connect to Rondevu with Node crypto adapter and ICE server preset + console.log('1. Connecting to Rondevu...') + const rondevu = await Rondevu.connect({ apiUrl: API_URL, username: USERNAME, - cryptoAdapter: new NodeCryptoAdapter() + cryptoAdapter: new NodeCryptoAdapter(), + iceServers: 'ipv4-turn' // Use preset: 'ipv4-turn', 'hostname-turns', 'google-stun', or 'relay-only' }) - await rondevu.initialize() - console.log(` ✓ Initialized as: ${rondevu.getUsername()}`) + console.log(` ✓ Connected as: ${rondevu.getUsername()}`) console.log(` ✓ Public key: ${rondevu.getPublicKey()?.substring(0, 20)}...`) // 2. Username will be auto-claimed on first authenticated request (publishService) @@ -341,7 +342,7 @@ import { Rondevu } from '@xtr-dev/rondevu-client' const API_URL = 'https://api.ronde.vu' const SERVICE_FQN = 'chat:2.0.0@chatbot' // Full service name with username -// TURN server configuration +// TURN server configuration for manual RTCPeerConnection setup const RTC_CONFIG = { iceServers: [ { urls: 'stun:stun.l.google.com:19302' }, @@ -359,14 +360,14 @@ const RTC_CONFIG = { async function connectToService() { console.log('🌐 Connecting to chat bot...') - // 1. Initialize Rondevu (anonymous user) - const rondevu = new Rondevu({ + // 1. Connect to Rondevu (anonymous user with ICE server preset) + const rondevu = await Rondevu.connect({ apiUrl: API_URL, + iceServers: 'ipv4-turn', // Use preset or custom config // No username = auto-generated anonymous username }) - await rondevu.initialize() - console.log(`✓ Initialized as: ${rondevu.getUsername()}`) + console.log(`✓ Connected as: ${rondevu.getUsername()}`) // 2. Discover service console.log(`Looking for service: ${SERVICE_FQN}`) diff --git a/src/App.jsx b/src/App.jsx index 4a8e557..fa687aa 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -175,13 +175,13 @@ export default function App() { // Check if we have a saved username and if it's claimed if (savedUsername && savedKeypair) { // Create Rondevu instance with saved credentials - const service = new Rondevu({ + const service = await Rondevu.connect({ apiUrl: API_URL, username: savedUsername, keypair: parsedKeypair, + iceServers: rtcPreset, // Use preset: 'ipv4-turn', 'hostname-turns', 'google-stun', or 'relay-only' }); - await service.initialize(); setRondevu(service); console.log('[Init] Checking if username is claimed...'); @@ -332,12 +332,12 @@ export default function App() { try { // Create new Rondevu instance (will generate keypair if needed) - const newService = new Rondevu({ + const newService = await Rondevu.connect({ apiUrl: API_URL, username: usernameInput, keypair: rondevu?.getKeypair(), // Use existing keypair if available, otherwise will generate new one + iceServers: rtcPreset, // Use preset: 'ipv4-turn', 'hostname-turns', 'google-stun', or 'relay-only' }); - await newService.initialize(); // Username will be auto-claimed on first publish const keypair = newService.getKeypair();