Address code review suggestions

- Update README.md example to match new OfferFactory signature
- Add error handling and RTCPeerConnection cleanup on factory failure
- Document setupIceCandidateHandler() method usage
- Use undefined instead of null for offerId variable

Co-authored-by: Bas <bvdaakster@users.noreply.github.com>
This commit is contained in:
claude[bot]
2025-12-14 10:21:43 +00:00
parent df231c192d
commit a0dc9ddad0
2 changed files with 19 additions and 5 deletions

View File

@@ -49,8 +49,8 @@ const rondevu = await Rondevu.connect({
await rondevu.publishService({
service: 'chat:1.0.0',
maxOffers: 5, // Maintain up to 5 concurrent offers
offerFactory: async (rtcConfig) => {
const pc = new RTCPeerConnection(rtcConfig)
offerFactory: async (pc) => {
// pc is created by Rondevu with ICE handlers already attached
const dc = pc.createDataChannel('chat')
dc.addEventListener('open', () => {
@@ -64,7 +64,7 @@ await rondevu.publishService({
const offer = await pc.createOffer()
await pc.setLocalDescription(offer)
return { pc, dc, offer }
return { dc, offer }
}
})