CRITICAL BUG FIX: As the answerer, we should NOT create our own data channel.
The host (offerer) creates the channel, and we receive it via ondatachannel event.
This was causing messages to be sent on a different channel than the one
the host was listening to, so no messages were being received.
Changes:
- Remove pc.createDataChannel() call
- Add pc.ondatachannel event handler
- Wrap data channel setup in setupDataChannel() function
- Called when channel is received from host
- Increase delay to 500ms before sending identify
- Monitor channel state before sending
- Log bufferedAmount after send
- Add onclose handler for debugging
- Send 'identify' message on connection
- Wait for 'identify_ack' acknowledgment
- Send 'message' type with text for chat
- Keep connection open 5s to receive responses
- Move onicecandidate handler setup before setLocalDescription
- Directly use API for sending candidates instead of signaler
- Use signaler only for receiving remote candidates
Better error message when wrtc is not installed, with clear
instructions on how to install it.
🤖 Generated with Claude Code
https://claude.com/claude-code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Adds test-connect.js script that:
- Connects to production Rondevu API
- Discovers chat service from @bas
- Establishes WebRTC connection using wrtc
- Sends 'hello' message via data channel
Usage: npm test
Requires:
- Node.js 19+ (or 18 with --experimental-global-webcrypto)
- wrtc package for WebRTC in Node.js
🤖 Generated with Claude Code
https://claude.com/claude-code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>