Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: Improve handshake resiliency of peer #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jan 31, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add diagram explaining handshake
  • Loading branch information
kylecarbs committed Jan 30, 2022
commit 90d26f2a22d338b74a0ab590725c04baf429bba3
16 changes: 16 additions & 0 deletions peer/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@ func (*Conn) hashCandidate(iceCandidate webrtc.ICECandidateInit) string {
return fmt.Sprintf("%x", hash[:8])
}

// Negotiate exchanges ICECandidate pairs over the exposed channels.
// The diagram below shows the expected handshake. pion/webrtc v3
// uses trickle ICE by default. See: https://webrtchacks.com/trickle-ice/
// ┌────────┐ ┌────────┐
// │offerrer│ │answerer│
// │(client)│ │(server)│
// └─┬────┬─┘ └─┬──────┘
// │ │ offer │
// ┌──────────▼┐ ├──────────────►├──►┌───────────┐
// │STUN Server│ │ │ │STUN Server│
// │(optional) ├──►│ candidate │◄──┤(optional) │
// └───────────┘ │ (async) │ └───────────┘
// │◄─────────────►│
// │ │
// │ answer │
// └◄──────────────┘
func (c *Conn) negotiate() {
c.opts.Logger.Debug(context.Background(), "negotiating")

Expand Down