<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>I added a lines:</div><div><br></div><div>print(self.engine.incoming_requests)</div><div dir="ltr">self.engine.add_incoming_request('INFO')<br></div><div dir="ltr">print(self.engine.incoming_requests)<br></div><div dir="ltr"><br></div><div>in the beginning of _NH_SIPApplicationDidStart method. As I can see, INFO method was added in set of methods,  but no SIPIncomingRequestGotRequest or even SIPEngineLog notifications handled. </div><div><br></div><div><div class="gmail-gs" style="margin:0px;padding:0px 0px 20px;width:700px;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><div class="gmail-"><div id="gmail-:l8" class="gmail-ii gmail-gt" style="font-size:12.8px;direction:ltr;margin:8px 0px 0px;padding:0px"><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif">> Keep in mind this only works for single-transaction out-of-dialog requests. In dialog requests will always be handled in dialog and will not generate an IncomingRequest object even if the method matches the ones in engine.incoming_requests</div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif"><br></div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif">How can I realize: is my INFO request connected with some dialog? </div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif">There is sequence of requests in Wireshark:</div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif">=> Request: INVITE</div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif"><= Status: 401 Unathorized<br><div class="gmail-adL">=> ACK</div><div class="gmail-adL"><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:1.5;overflow:hidden">=> Request: INVITE</div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:1.5;overflow:hidden"><= Status: 100 Trying</div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:1.5;overflow:hidden"><= Request: INFO</div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:1.5;overflow:hidden">=> Status: 500 Unhandled by dialog usages</div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:1.5;overflow:hidden"><br></div><div id="gmail-:l7" class="gmail-a3s gmail-aXjCH" style="font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;line-height:1.5;overflow:hidden">Invite requests were sent by session object and I have to handle incoming INFO request.</div></div></div></div><div class="gmail-hi" style="border-bottom-left-radius:1px;border-bottom-right-radius:1px;padding:0px;width:auto;background:rgb(242,242,242);margin:0px"></div></div></div><br class="gmail-Apple-interchange-newline"></div><div><br></div><div dir="ltr"><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">пт, 15 мар. 2019 г. в 01:05, <<a href="mailto:sipbeyondvoip-request@lists.ag-projects.com">sipbeyondvoip-request@lists.ag-projects.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Send SIPBeyondVoIP mailing list submissions to<br>
        <a href="mailto:sipbeyondvoip@lists.ag-projects.com" target="_blank">sipbeyondvoip@lists.ag-projects.com</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip" rel="noreferrer" target="_blank">http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip</a><br>
or, via email, send a message with subject or body 'help' to<br>
        <a href="mailto:sipbeyondvoip-request@lists.ag-projects.com" target="_blank">sipbeyondvoip-request@lists.ag-projects.com</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:sipbeyondvoip-owner@lists.ag-projects.com" target="_blank">sipbeyondvoip-owner@lists.ag-projects.com</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of SIPBeyondVoIP digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
   1. Problem with SIP Simple SDK notification handling<br>
      (Alexey Nikitenko)<br>
   2. Re: Problem with SIP Simple SDK notification      handling (Dan Pascu)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Thu, 14 Mar 2019 21:47:48 +1000<br>
From: Alexey Nikitenko <<a href="mailto:alexeynikitenko1927@gmail.com" target="_blank">alexeynikitenko1927@gmail.com</a>><br>
To: <a href="mailto:sipbeyondvoip@lists.ag-projects.com" target="_blank">sipbeyondvoip@lists.ag-projects.com</a><br>
Subject: [SIP Beyond VoIP] Problem with SIP Simple SDK notification<br>
        handling<br>
Message-ID:<br>
        <<a href="mailto:CAESrG6QL6PQpSR2-wUn7FZMzWuUeXbWPJhAYH-DmxJOnqg-Eug@mail.gmail.com" target="_blank">CAESrG6QL6PQpSR2-wUn7FZMzWuUeXbWPJhAYH-DmxJOnqg-Eug@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
I try to handle notifications in my simple sip application. I can handle<br>
many notifications connected with session, application end engine, but I<br>
can't handle notifications, connected with incoming and outgoing low-level<br>
requests.<br>
<br>
There is incoming INFO messages is session, I can see in Wireshark, but it<br>
not handled with _NH_SIPIncomingRequestGotRequest.<br>
<br>
Full listing of class:<br>
<br>
class SimpleCallApplication(SIPApplication):<br>
<br>
def __init__(self, number, password, server_ip, server_port, logger):<br>
SIPApplication.__init__(self)<br>
self.logger = logger<br>
self.ended = Event()<br>
self.session = None<br>
self.uri = None<br>
self.player = None<br>
self._wave_file = None<br>
self.number = number<br>
self.password = password<br>
self.domain = '{}:{}'.format(server_ip, server_port)<br>
self.number_with_domain = '{}@{}'.format(number, self.domain)<br>
self.notification_center = NotificationCenter()<br>
self.notification_center.add_observer(self)<br>
<br>
def call(self, uri, filename):<br>
self.uri = uri<br>
self._wave_file = filename<br>
self.start(FileStorage('config'))<br>
<br>
@run_in_green_thread<br>
def _NH_SIPApplicationDidStart(self, notification):<br>
<br>
acc = None<br>
try:<br>
acc = AccountManager().get_account(self.number_with_domain)<br>
except KeyError:<br>
pass<br>
if acc is not None:<br>
self.account = acc<br>
else:<br>
self.account = Account(self.number_with_domain)<br>
<br>
self.account.__setstate__({'password': self.password})<br>
self.account.enabled = True<br>
self.account.save()<br>
<br>
to = ToHeader(SIPURI.parse(self.uri))<br>
settings = SIPSimpleSettings()<br>
settings.audio.input_device = None<br>
settings.audio.output_device = None<br>
settings.save()<br>
self.player = WavePlayer(SIPApplication.voice_audio_mixer, self._wave_file,<br>
loop_count=1)<br>
try:<br>
lookup = DNSLookup()<br>
routes = lookup.lookup_sip_proxy(to.uri, ['udp']).wait()<br>
except DNSLookupError, e:<br>
print 'DNS lookup failed: %s' % str(e)<br>
else:<br>
self.session = Session(self.account)<br>
stream = AudioStream()<br>
<br>
self.session.connect(to, routes, [stream])<br>
<br>
def _NH_SIPSessionGotRingIndication(self, notification):<br>
print 'Ringing!'<br>
session = notification.sender<br>
session.send(struct.pack('>BBBB', 1, 2, 3, 4))<br>
<br>
def _NH_SIPSessionDidStart(self, notification):<br>
print 'Session started!'<br>
session = notification.sender<br>
audio_stream = session.streams[0]<br>
audio_stream.bridge.add(self.player)<br>
self.player.play()<br>
<br>
def _NH_SIPSessionDidFail(self, notification):<br>
print 'Failed to connect'<br>
self.stop()<br>
<br>
def _NH_SIPSessionWillEnd(self, notification):<br>
session = notification.sender<br>
audio_stream = session.streams[0]<br>
self.player.stop()<br>
audio_stream.bridge.remove(self.player)<br>
<br>
def _NH_SIPSessionDidEnd(self, notification):<br>
print 'Session ended'<br>
self.stop()<br>
<br>
def _NH_SIPApplicationDidEnd(self, notification):<br>
self.ended.set()<br>
<br>
def _NH_AudioStreamGotDTMF(self, notification):<br>
print 'DTMF detected! {}'.format(notification.data.__dict__)<br>
<br>
def _NH_SIPIncomingRequestGotRequest(self, notification):<br>
print 'Incoming request'<br>
<br>
def _NH_SIPInvitationGotSDPUpdate(self, notification):<br>
print 'SDP update: {}'.format(notification.sender.state)<br>
<br>
def _NH_SIPRequestDidEnd(self, notification):<br>
print 'request ended'<br>
<br>
def _NH_SIPEngineLog(self, notification):<br>
print 'got a log!'<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190314/7117451d/attachment-0001.html" rel="noreferrer" target="_blank">http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190314/7117451d/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Thu, 14 Mar 2019 17:05:24 +0200<br>
From: Dan Pascu <<a href="mailto:dan@ag-projects.com" target="_blank">dan@ag-projects.com</a>><br>
To: SIP Beyond VoIP <<a href="mailto:sipbeyondvoip@lists.ag-projects.com" target="_blank">sipbeyondvoip@lists.ag-projects.com</a>><br>
Subject: Re: [SIP Beyond VoIP] Problem with SIP Simple SDK<br>
        notification    handling<br>
Message-ID: <<a href="mailto:5D006E0E-3F65-4BF9-ADFA-C9001D9CAD56@ag-projects.com" target="_blank">5D006E0E-3F65-4BF9-ADFA-C9001D9CAD56@ag-projects.com</a>><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
<br>
On 14 Mar 2019, at 13:47, Alexey Nikitenko wrote:<br>
<br>
> I try to handle notifications in my simple sip application. I can handle many notifications connected with session, application end engine, but I can't handle notifications, connected with incoming and outgoing low-level requests.<br>
<br>
By default no request is handled as a low level request. In order to have some requests handled as low level ones you need to indicate that by passing incoming_requests=[list_of_method_names] as an argument to Engine.start<br>
<br>
If you use SIPApplication, it will start the engine without passing any incoming_requests. In that case you need to call add_incoming_request on the Engine after you got SIPApplicationDidStart to add them on the fly at runtime.<br>
<br>
Keep in mind this only works for single-transaction out-of-dialog requests. In dialog requests will always be handled in dialog and will not generate an IncomingRequest object even if the method matches the ones in engine.incoming_requests<br>
<br>
In this particular example you'll have to add<br>
<br>
self.engine.add_incoming_request('INFO')<br>
<br>
in the beginning of _NH_SIPApplicationDidStart<br>
<br>
Check the documentation here:<br>
<br>
<a href="http://old.sipsimpleclient.org/projects/sipsimpleclient/wiki/SipCoreApiDocumentation#IncomingRequest" rel="noreferrer" target="_blank">http://old.sipsimpleclient.org/projects/sipsimpleclient/wiki/SipCoreApiDocumentation#IncomingRequest</a><br>
<br>
> <br>
> There is incoming INFO messages is session, I can see in Wireshark, but it not handled with _NH_SIPIncomingRequestGotRequest. <br>
> <br>
> Full listing of class: <br>
> <br>
> class SimpleCallApplication(SIPApplication):<br>
> <br>
>     def __init__(self, number, password, server_ip, server_port, logger):<br>
>         SIPApplication.__init__(self)<br>
>         self.logger = logger<br>
>         self.ended = Event()<br>
>         self.session = None<br>
>         self.uri = None<br>
>         self.player = None<br>
>         self._wave_file = None<br>
>         self.number = number<br>
>         self.password = password<br>
>         self.domain = '{}:{}'.format(server_ip, server_port)<br>
>         self.number_with_domain = '{}@{}'.format(number, self.domain)<br>
>         self.notification_center = NotificationCenter()<br>
>         self.notification_center.add_observer(self)<br>
> <br>
>     def call(self, uri, filename):<br>
>         self.uri = uri<br>
>         self._wave_file = filename<br>
>         self.start(FileStorage('config'))<br>
> <br>
>     @run_in_green_thread<br>
>     def _NH_SIPApplicationDidStart(self, notification):<br>
> <br>
>         acc = None<br>
>         try:<br>
>             acc = AccountManager().get_account(self.number_with_domain)<br>
>         except KeyError:<br>
>             pass<br>
>         if acc is not None:<br>
>             self.account = acc<br>
>         else:<br>
>             self.account = Account(self.number_with_domain)<br>
> <br>
>         self.account.__setstate__({'password': self.password})<br>
>         self.account.enabled = True<br>
>         self.account.save()<br>
> <br>
>         to = ToHeader(SIPURI.parse(self.uri))<br>
>         settings = SIPSimpleSettings()<br>
>         settings.audio.input_device = None<br>
>         settings.audio.output_device = None<br>
>         settings.save()<br>
>         self.player = WavePlayer(SIPApplication.voice_audio_mixer, self._wave_file, loop_count=1)<br>
>         try:<br>
>             lookup = DNSLookup()<br>
>             routes = lookup.lookup_sip_proxy(to.uri, ['udp']).wait()<br>
>         except DNSLookupError, e:<br>
>             print 'DNS lookup failed: %s' % str(e)<br>
>         else:<br>
>             self.session = Session(self.account)<br>
>             stream = AudioStream()<br>
> <br>
>             self.session.connect(to, routes, [stream])<br>
> <br>
>     def _NH_SIPSessionGotRingIndication(self, notification):<br>
>         print 'Ringing!'<br>
>         session = notification.sender<br>
>         session.send(struct.pack('>BBBB', 1, 2, 3, 4))<br>
> <br>
>     def _NH_SIPSessionDidStart(self, notification):<br>
>         print 'Session started!'<br>
>         session = notification.sender<br>
>         audio_stream = session.streams[0]<br>
>         audio_stream.bridge.add(self.player)<br>
>         self.player.play()<br>
> <br>
>     def _NH_SIPSessionDidFail(self, notification):<br>
>         print 'Failed to connect'<br>
>         self.stop()<br>
> <br>
>     def _NH_SIPSessionWillEnd(self, notification):<br>
>         session = notification.sender<br>
>         audio_stream = session.streams[0]<br>
>         self.player.stop()<br>
>         audio_stream.bridge.remove(self.player)<br>
> <br>
>     def _NH_SIPSessionDidEnd(self, notification):<br>
>         print 'Session ended'<br>
>         self.stop()<br>
> <br>
>     def _NH_SIPApplicationDidEnd(self, notification):<br>
>         self.ended.set()<br>
> <br>
>     def _NH_AudioStreamGotDTMF(self, notification):<br>
>         print 'DTMF detected! {}'.format(notification.data.__dict__)<br>
> <br>
>     def _NH_SIPIncomingRequestGotRequest(self, notification):<br>
>         print 'Incoming request'<br>
> <br>
>     def _NH_SIPInvitationGotSDPUpdate(self, notification):<br>
>         print 'SDP update: {}'.format(notification.sender.state)<br>
> <br>
>     def _NH_SIPRequestDidEnd(self, notification):<br>
>         print 'request ended'<br>
> <br>
>     def _NH_SIPEngineLog(self, notification):<br>
>         print 'got a log!' <br>
> _______________________________________________<br>
> SIPBeyondVoIP mailing list<br>
> <a href="mailto:SIPBeyondVoIP@lists.ag-projects.com" target="_blank">SIPBeyondVoIP@lists.ag-projects.com</a><br>
> <a href="http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip" rel="noreferrer" target="_blank">http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip</a><br>
<br>
<br>
--<br>
Dan<br>
<br>
<br>
<br>
<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
SIPBeyondVoIP mailing list<br>
<a href="mailto:SIPBeyondVoIP@lists.ag-projects.com" target="_blank">SIPBeyondVoIP@lists.ag-projects.com</a><br>
<a href="http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip" rel="noreferrer" target="_blank">http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip</a><br>
<br>
<br>
End of SIPBeyondVoIP Digest, Vol 105, Issue 1<br>
*********************************************<br>
</blockquote></div>