CallHandler class
CallHandler - Single Source of Truth for Call State Management
The CallHandler class serves as the centralized state management system for all call state changes within the Telnyx WebRTC SDK. It ensures consistent state transitions and guarantees that state change callbacks are always triggered when the call state is modified.
Key Responsibilities:
- Maintains the authoritative call state for each Call instance
- Ensures all state changes trigger the registered callback
- Provides a consistent interface for state management across the SDK
Usage Pattern:
Instead of directly modifying call.callState
, use callHandler.changeState(newState)
to ensure
proper state management and callback execution.
Access Points Throughout SDK:
call.dart
: Used inendCall()
,onHoldUnholdPressed()
methodstelnyx_client.dart
: Used for new calls, connections, and call terminationpeer/peer.dart
: Used when WebRTC connection becomes active
Example:
// Correct way to change call state
callHandler.changeState(CallState.active);
// This ensures both the state is updated AND the callback is triggered
Constructors
- CallHandler.new(CallStateCallback onCallStateChanged, Call? call)
- Creates a new CallHandler instance
Properties
- call ↔ Call?
-
Reference to the associated Call instance whose state this handler manages
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- onCallStateChanged ↔ CallStateCallback
-
Callback function that gets invoked whenever the call state changes
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
changeState(
CallState state) → void - Primary State Change Method - Use This Instead of Direct Assignment
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited