Skip to content

Commit 90d26f2

Browse files
committed
Add diagram explaining handshake
1 parent 86cb3d4 commit 90d26f2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

peer/conn.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,22 @@ func (*Conn) hashCandidate(iceCandidate webrtc.ICECandidateInit) string {
288288
return fmt.Sprintf("%x", hash[:8])
289289
}
290290

291+
// Negotiate exchanges ICECandidate pairs over the exposed channels.
292+
// The diagram below shows the expected handshake. pion/webrtc v3
293+
// uses trickle ICE by default. See: https://webrtchacks.com/trickle-ice/
294+
// ┌────────┐ ┌────────┐
295+
// │offerrer│ │answerer│
296+
// │(client)│ │(server)│
297+
// └─┬────┬─┘ └─┬──────┘
298+
// │ │ offer │
299+
// ┌──────────▼┐ ├──────────────►├──►┌───────────┐
300+
// │STUN Server│ │ │ │STUN Server│
301+
// │(optional) ├──►│ candidate │◄──┤(optional) │
302+
// └───────────┘ │ (async) │ └───────────┘
303+
// │◄─────────────►│
304+
// │ │
305+
// │ answer │
306+
// └◄──────────────┘
291307
func (c *Conn) negotiate() {
292308
c.opts.Logger.Debug(context.Background(), "negotiating")
293309

0 commit comments

Comments
 (0)