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
235 stars 109 forks source link

[2.0.0a4] - 486-BUSY not processing in call.py + Solution #244

Open Wufus opened 9 months ago

Wufus commented 9 months ago

It seems, that when we call via phone.call and the server answer 486-BUSY asterisk extension..conf exten => _X,1,Busy() The code isn't processing this status/response. So to fix it, i add two line in the call.py to next block

if message.type is SIPMessageType.RESPONSE:
                if message.status is SIPStatus.OK:
                    if self.state in [
                        CallState.DIALING,
                        CallState.RINGING,
                        CallState.PROGRESS,
                    ]:
                        self.answered(message)
                elif message.status == SIPStatus.BUSY_HERE:  # <-- 
                    self.busy(message)                       # <--
                elif message.status == SIPStatus.NOT_FOUND:
                    pass
            else:
                if message.method == "BYE":

Now I can receive this event in my inheriting class

class MyCall(VoIPCall):
    def busy(self, request):
        print('Call ended - callee is busy')
        super().busy(request)