Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Project: private peer consultation

Last updated: 5 Oct 20268 min read
project
IntermediateBy AITrove Editorial

Build a consultation for reviewers 29 and 47 on case 62. The room checks current case membership before either browser subscribes to signaling and before each forwarded offer, answer, or candidate. A signal envelope includes room, sender, recipient, generation, message type, and a bounded payload. Old generations are ignored after reconnect. The user starts an audio-only capture from an explicit control; a denied prompt leaves typed notes available. Each acquired local track stops on leave, revocation, failed setup, and page navigation. Configure scoped relay credentials so a network without a direct path can still connect. Show a timed recovery attempt and then a text fallback when media cannot recover. A data channel carries small ephemeral pointer hints with a queue cap and coalescing. Actual case notes use the authorized server API with revision and idempotency rules, so they survive peer closure. Keep media bytes, private case text, and raw network addresses out of routine signaling logs.

Build contract

  • Deny a removed reviewer both subscription and a late candidate message.
  • Test a late answer from an older generation and a relay-only network.
  • Stop every local audio track after setup failure or explicit leave.
  • Throttle the data channel and keep durable notes in the server record.

Implementation checkpoint

javascript
function admitRoomSignal(memberAllowed, activeGeneration, messageGeneration) {
  return memberAllowed && activeGeneration === messageGeneration;
}
console.log(admitRoomSignal(false, 6, 6));
// Output: false

Cost and boundaries

Signaling messages are small but candidate bursts and repeated retries need caps. Relay traffic costs bandwidth proportional to call duration and media rate, so measure relay share and capacity. Audio capture spends device power even if no peer connects; stop it promptly. Pointer hints can outnumber useful frames, so coalesce replaceable events and limit queued bytes. Measure setup time, leave-to-stop delay, restart success, and note-save conflicts without logging media or private annotations.

Failure drill

Reject room ID guessing, a revoked reviewer, and generation 5 messages after generation 6 starts. Deny microphone permission and verify the text path still works. Block direct candidates and prove the relay path. Expire relay credentials and make recovery stop at its budget. Send 62 pointer hints into a slow connection and keep buffered bytes under the cap. Save a case note, close both tabs, and reload: the note must remain in the authorized server record.

Acceptance checks

  • Room membership is enforced on each signal.
  • Local tracks stop on every terminal path.
  • Relay failure has a bounded fallback.
  • Peer messages never substitute for durable case writes.

Common Mistakes

  • Using a room ID as an access grant.
  • Calling offer-answer exchange a connected call.
  • Treating a queued hint as a saved case note.

Related lessons

Media Capture Consent and Track Lifecycle; WebRTC Signaling, Room Authorization, and Offer Order; WebRTC ICE, TURN Fallback, and Session Recovery; Data Channel Backpressure and Peer State.

web-tech
web-development
Storage details