Overview
TheGatheringState enum describes the current state of the ICE candidate gathering process. It tracks whether the agent is discovering local network addresses and querying STUN/TURN servers.
Type Definition
States
GatheringStateNew
GatherCandidates() has not been called.
GatheringStateGathering
- Discovering local network interfaces
- Creating host candidates
- Querying STUN servers for server reflexive candidates
- Allocating TURN relays for relay candidates
GatheringStateComplete
GatheringStateUnknown
Methods
String
"new"for GatheringStateNew"gathering"for GatheringStateGathering"complete"for GatheringStateComplete- Error string for unknown states
State Transitions
Transitions:- New → Gathering: When
GatherCandidates()is called - Gathering → Complete: When all gathering operations finish
- Complete → Gathering: When using continual gathering and new interfaces appear
Usage Example
Continual Gathering
When continual gathering is enabled, the state can transition back from Complete to Gathering when new network interfaces are detected:Gathering Timeout
You can configure how long to wait for STUN server responses:Gathering Complete Signal
The agent signals gathering completion by calling theOnCandidate handler with a nil candidate:
Continual Gathering Policy
GatherOnce (Default)
Gathering completes after the initial phase and stops monitoring for new interfaces.GatherContinually
The agent continuously monitors network interfaces and gathers new candidates when changes are detected.Related
- Agent - ICE Agent with gathering methods
- ConnectionState - Connection state enum
- Candidate Types - Types of ICE candidates