mirror of
https://github.com/xtr-dev/rondevu-demo.git
synced 2025-12-15 12:33:23 +00:00
Update test-connect.js to use Rondevu.connect() and ICE presets
- Replace new Rondevu() + initialize() with Rondevu.connect() - Use 'ipv4-turn' ICE server preset - Use rondevu.addOfferIceCandidates() directly (no getAPIPublic()) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,7 +40,8 @@ const TARGET_USER = 'bas'
|
|||||||
const SERVICE_FQN = `chat:2.0.0@${TARGET_USER}`
|
const SERVICE_FQN = `chat:2.0.0@${TARGET_USER}`
|
||||||
const MESSAGE = 'hello'
|
const MESSAGE = 'hello'
|
||||||
|
|
||||||
// TURN server configuration (IPv4 TURN only - matches demo default)
|
// TURN server configuration for manual RTCPeerConnection setup
|
||||||
|
// Note: Answerer uses manual RTCPeerConnection, not automatic offer management
|
||||||
const RTC_CONFIG = {
|
const RTC_CONFIG = {
|
||||||
iceServers: [
|
iceServers: [
|
||||||
{ urls: 'stun:57.129.61.67:3478' },
|
{ urls: 'stun:57.129.61.67:3478' },
|
||||||
@@ -60,16 +61,16 @@ async function main() {
|
|||||||
console.log('='.repeat(50))
|
console.log('='.repeat(50))
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 1. Initialize Rondevu with Node crypto adapter
|
// 1. Connect to Rondevu with Node crypto adapter and ICE preset
|
||||||
console.log('1. Initializing Rondevu client...')
|
console.log('1. Connecting to Rondevu...')
|
||||||
const rondevu = new Rondevu({
|
const rondevu = await Rondevu.connect({
|
||||||
apiUrl: API_URL,
|
apiUrl: API_URL,
|
||||||
username: `test-${Date.now()}`, // Anonymous test user
|
username: `test-${Date.now()}`, // Anonymous test user
|
||||||
cryptoAdapter: new NodeCryptoAdapter()
|
cryptoAdapter: new NodeCryptoAdapter(),
|
||||||
|
iceServers: 'ipv4-turn' // Use ICE server preset
|
||||||
})
|
})
|
||||||
|
|
||||||
await rondevu.initialize()
|
console.log(` ✓ Connected as: ${rondevu.getUsername()}`)
|
||||||
console.log(` ✓ Initialized as: ${rondevu.getUsername()}`)
|
|
||||||
console.log(` ✓ Public key: ${rondevu.getPublicKey()?.substring(0, 20)}...`)
|
console.log(` ✓ Public key: ${rondevu.getPublicKey()?.substring(0, 20)}...`)
|
||||||
|
|
||||||
// 2. Discover service
|
// 2. Discover service
|
||||||
@@ -181,7 +182,7 @@ async function main() {
|
|||||||
sdpMid: event.candidate.sdpMid,
|
sdpMid: event.candidate.sdpMid,
|
||||||
usernameFragment: event.candidate.usernameFragment
|
usernameFragment: event.candidate.usernameFragment
|
||||||
}
|
}
|
||||||
await rondevu.getAPIPublic().addOfferIceCandidates(
|
await rondevu.addOfferIceCandidates(
|
||||||
serviceData.serviceFqn,
|
serviceData.serviceFqn,
|
||||||
serviceData.offerId,
|
serviceData.offerId,
|
||||||
[candidateInit]
|
[candidateInit]
|
||||||
|
|||||||
Reference in New Issue
Block a user