stateΒΆ

class UASCallChannel
state(check_for_hangup=False)

Return the call state.

Optional argument:
  • check_for_hangup

    option to raise a Hangup exception on IDLE. Default is False.

This function returns the current call state.

The check_for_hangup parameter is provided as an explicit method of raising a Hangup exception on IDLE.

Usage example:

# reject the call and then and raise a Hangup
# exception on IDLE
try:
    if channel.reject(cause=channel.Cause.BUSY) != channel.State.IDLE:
        # wait for channel to go to idle
        channel.wait_for_idle(None)
        # will throw Hangup
        channel.state(check_for_hangup=True)
except Hangup:
    # call is IDLE
    pass