tayler6000 / pyVoIP

Pure python VoIP/SIP/RTP library. Currently supports PCMA, PCMU, and telephone-event
https://pypi.org/project/pyVoIP/
GNU General Public License v3.0
194 stars 85 forks source link

call state real time #255

Open thiva7 opened 1 month ago

thiva7 commented 1 month ago

Hey ,

trying to get call state in "real time" but is not work

my example code

def answer(call): 
    try:
        print("call state is ", call.state)
        while True:
            if call.state == CallState.ENDED:
                print("Call ended")
            elif call.state == CallState.ANSWERED:
                print("Call answered")
            elif call.state == CallState.RINGING:
                print("Ringing")
            elif call.state == CallState.DIALING:
                print("Dialing")
            else:
                print("Call state is ", call.state)
            time.sleep(1)

when i make the call is print state ("Ringing") but even if i end the call without anwser from my phone is keep print Ringing , how i can make it to get current call state?

Thank you

s-manterola commented 3 weeks ago

try:

if str(call.state) == 'CallState.ENDED'

thiva7 commented 3 weeks ago

try:

if str(call.state) == 'CallState.ENDED'

not work , but what the point to check call.state as CallState.ENDED string?