<div dir="ltr">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.<div><br></div><div>There is incoming INFO messages is session, I can see in Wireshark, but it not handled with <span style="background-color:rgb(255,255,254);color:rgb(191,38,0);font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-size:13px;font-weight:700;white-space:pre">_NH_SIPIncomingRequestGotRequest.</span> </div><div><div><br></div><div>Full listing of class: <div><br></div><div style="color:rgb(0,0,0);background-color:rgb(255,255,254);font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-size:13px;line-height:18px;white-space:pre"><div><span style="color:rgb(0,73,176);font-weight:bold">class </span><span style="color:rgb(166,36,0);font-weight:bold">SimpleCallApplication</span>(<span style="color:rgb(32,32,32)">SIPApplication</span>):</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">__init__</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">number</span>, <span style="color:rgb(32,32,32)">password</span>, <span style="color:rgb(32,32,32)">server_ip</span>, <span style="color:rgb(32,32,32)">server_port</span>, <span style="color:rgb(32,32,32)">logger</span>):</div><div>        <span style="color:rgb(32,32,32)">SIPApplication</span>.__<span style="color:rgb(32,32,32)">init__</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>)</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">logger</span> = <span style="color:rgb(32,32,32)">logger</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">ended</span> = <span style="color:rgb(32,32,32)">Event</span>()</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">session</span> = <span style="color:rgb(101,84,192)">None</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">uri</span> = <span style="color:rgb(101,84,192)">None</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">player</span> = <span style="color:rgb(101,84,192)">None</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>._<span style="color:rgb(32,32,32)">wave_file</span> = <span style="color:rgb(101,84,192)">None</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">number</span> = <span style="color:rgb(32,32,32)">number</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">password</span> = <span style="color:rgb(32,32,32)">password</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">domain</span> = <span style="color:rgb(9,101,69)">'{}:{}'</span>.<span style="color:rgb(9,30,66);font-weight:bold">format</span>(<span style="color:rgb(32,32,32)">server_ip</span>, <span style="color:rgb(32,32,32)">server_port</span>)</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">number_with_domain</span> = <span style="color:rgb(9,101,69)">'{}@{}'</span>.<span style="color:rgb(9,30,66);font-weight:bold">format</span>(<span style="color:rgb(32,32,32)">number</span>, <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">domain</span>)</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">notification_center</span> = <span style="color:rgb(32,32,32)">NotificationCenter</span>()</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">notification_center</span>.<span style="color:rgb(32,32,32)">add_observer</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>)</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">call</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">uri</span>, <span style="color:rgb(32,32,32)">filename</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">uri</span> = <span style="color:rgb(32,32,32)">uri</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>._<span style="color:rgb(32,32,32)">wave_file</span> = <span style="color:rgb(32,32,32)">filename</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">start</span>(<span style="color:rgb(32,32,32)">FileStorage</span>(<span style="color:rgb(9,101,69)">'config'</span>))</div><br><div>    <span style="color:rgb(128,0,0)">@run_in_green_thread</span></div><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPApplicationDidStart</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><br><div>        <span style="color:rgb(32,32,32)">acc</span> = <span style="color:rgb(101,84,192)">None</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">try</span>:</div><div>            <span style="color:rgb(32,32,32)">acc</span> = <span style="color:rgb(32,32,32)">AccountManager</span>().<span style="color:rgb(32,32,32)">get_account</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">number_with_domain</span>)</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">except</span> <span style="color:rgb(32,32,32)">KeyError</span>:</div><div>            <span style="color:rgb(9,30,66);font-weight:bold">pass</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">if</span> <span style="color:rgb(32,32,32)">acc</span> <span style="color:rgb(9,30,66);font-weight:bold">is</span> <span style="color:rgb(9,30,66);font-weight:bold">not</span> <span style="color:rgb(101,84,192)">None</span>:</div><div>            <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">account</span> = <span style="color:rgb(32,32,32)">acc</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">else</span>:</div><div>            <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">account</span> = <span style="color:rgb(32,32,32)">Account</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">number_with_domain</span>)</div><br><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">account</span>.__<span style="color:rgb(32,32,32)">setstate__</span>({<span style="color:rgb(9,101,69)">'password'</span>: <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">password</span>})</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">account</span>.<span style="color:rgb(32,32,32)">enabled</span> = <span style="color:rgb(101,84,192)">True</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">account</span>.<span style="color:rgb(32,32,32)">save</span>()</div><br><div>        <span style="color:rgb(32,32,32)">to</span> = <span style="color:rgb(32,32,32)">ToHeader</span>(<span style="color:rgb(101,84,192)">SIPURI</span>.<span style="color:rgb(32,32,32)">parse</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">uri</span>))</div><div>        <span style="color:rgb(32,32,32)">settings</span> = <span style="color:rgb(32,32,32)">SIPSimpleSettings</span>()</div><div>        <span style="color:rgb(32,32,32)">settings</span>.<span style="color:rgb(32,32,32)">audio</span>.<span style="color:rgb(32,32,32)">input_device</span> = <span style="color:rgb(101,84,192)">None</span></div><div>        <span style="color:rgb(32,32,32)">settings</span>.<span style="color:rgb(32,32,32)">audio</span>.<span style="color:rgb(32,32,32)">output_device</span> = <span style="color:rgb(101,84,192)">None</span></div><div>        <span style="color:rgb(32,32,32)">settings</span>.<span style="color:rgb(32,32,32)">save</span>()</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">player</span> = <span style="color:rgb(32,32,32)">WavePlayer</span>(<span style="color:rgb(32,32,32)">SIPApplication</span>.<span style="color:rgb(32,32,32)">voice_audio_mixer</span>, <span style="color:rgb(9,30,66);font-weight:bold">self</span>._<span style="color:rgb(32,32,32)">wave_file</span>, <span style="color:rgb(32,32,32)">loop_count</span>=<span style="color:rgb(101,84,192)">1</span>)</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">try</span>:</div><div>            <span style="color:rgb(32,32,32)">lookup</span> = <span style="color:rgb(32,32,32)">DNSLookup</span>()</div><div>            <span style="color:rgb(32,32,32)">routes</span> = <span style="color:rgb(32,32,32)">lookup</span>.<span style="color:rgb(32,32,32)">lookup_sip_proxy</span>(<span style="color:rgb(32,32,32)">to</span>.<span style="color:rgb(32,32,32)">uri</span>, [<span style="color:rgb(9,101,69)">'udp'</span>]).<span style="color:rgb(32,32,32)">wait</span>()</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">except</span> <span style="color:rgb(32,32,32)">DNSLookupError</span>, <span style="color:rgb(32,32,32)">e</span>:</div><div>            <span style="color:rgb(9,30,66);font-weight:bold">print</span> <span style="color:rgb(9,101,69)">'DNS lookup failed: %s'</span> % <span style="color:rgb(9,30,66);font-weight:bold">str</span>(<span style="color:rgb(32,32,32)">e</span>)</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">else</span>:</div><div>            <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">session</span> = <span style="color:rgb(32,32,32)">Session</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">account</span>)</div><div>            <span style="color:rgb(32,32,32)">stream</span> = <span style="color:rgb(32,32,32)">AudioStream</span>()</div><div><br></div><div>            <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">session</span>.<span style="color:rgb(32,32,32)">connect</span>(<span style="color:rgb(32,32,32)">to</span>, <span style="color:rgb(32,32,32)">routes</span>, [<span style="color:rgb(32,32,32)">stream</span>])</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPSessionGotRingIndication</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">print</span> <span style="color:rgb(9,101,69)">'Ringing!'</span></div><div>        <span style="color:rgb(32,32,32)">session</span> = <span style="color:rgb(32,32,32)">notification</span>.<span style="color:rgb(32,32,32)">sender</span></div><div>        <span style="color:rgb(32,32,32)">session</span>.<span style="color:rgb(32,32,32)">send</span>(<span style="color:rgb(32,32,32)">struct</span>.<span style="color:rgb(32,32,32)">pack</span>(<span style="color:rgb(9,101,69)">'>BBBB'</span>, <span style="color:rgb(101,84,192)">1</span>, <span style="color:rgb(101,84,192)">2</span>, <span style="color:rgb(101,84,192)">3</span>, <span style="color:rgb(101,84,192)">4</span>))</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPSessionDidStart</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">print</span> <span style="color:rgb(9,101,69)">'Session started!'</span></div><div>        <span style="color:rgb(32,32,32)">session</span> = <span style="color:rgb(32,32,32)">notification</span>.<span style="color:rgb(32,32,32)">sender</span></div><div>        <span style="color:rgb(32,32,32)">audio_stream</span> = <span style="color:rgb(32,32,32)">session</span>.<span style="color:rgb(32,32,32)">streams</span>[<span style="color:rgb(101,84,192)">0</span>]</div><div>        <span style="color:rgb(32,32,32)">audio_stream</span>.<span style="color:rgb(32,32,32)">bridge</span>.<span style="color:rgb(32,32,32)">add</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">player</span>)</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">player</span>.<span style="color:rgb(32,32,32)">play</span>()</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPSessionDidFail</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">print</span> <span style="color:rgb(9,101,69)">'Failed to connect'</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">stop</span>()</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPSessionWillEnd</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(32,32,32)">session</span> = <span style="color:rgb(32,32,32)">notification</span>.<span style="color:rgb(32,32,32)">sender</span></div><div>        <span style="color:rgb(32,32,32)">audio_stream</span> = <span style="color:rgb(32,32,32)">session</span>.<span style="color:rgb(32,32,32)">streams</span>[<span style="color:rgb(101,84,192)">0</span>]</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">player</span>.<span style="color:rgb(32,32,32)">stop</span>()</div><div>        <span style="color:rgb(32,32,32)">audio_stream</span>.<span style="color:rgb(32,32,32)">bridge</span>.<span style="color:rgb(32,32,32)">remove</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">player</span>)</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPSessionDidEnd</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">print</span> <span style="color:rgb(9,101,69)">'Session ended'</span></div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">stop</span>()</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPApplicationDidEnd</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">self</span>.<span style="color:rgb(32,32,32)">ended</span>.<span style="color:rgb(9,30,66);font-weight:bold">set</span>()</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_AudioStreamGotDTMF</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">print</span> <span style="color:rgb(9,101,69)">'DTMF detected! {}'</span>.<span style="color:rgb(9,30,66);font-weight:bold">format</span>(<span style="color:rgb(32,32,32)">notification</span>.<span style="color:rgb(32,32,32)">data</span>.__<span style="color:rgb(32,32,32)">dict__</span>)</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPIncomingRequestGotRequest</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">print</span> <span style="color:rgb(9,101,69)">'Incoming request'</span></div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPInvitationGotSDPUpdate</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">print</span> <span style="color:rgb(9,101,69)">'SDP update: {}'</span>.<span style="color:rgb(9,30,66);font-weight:bold">format</span>(<span style="color:rgb(32,32,32)">notification</span>.<span style="color:rgb(32,32,32)">sender</span>.<span style="color:rgb(32,32,32)">state</span>)</div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPRequestDidEnd</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div><div>        <span style="color:rgb(9,30,66);font-weight:bold">print</span> <span style="color:rgb(9,101,69)">'request ended'</span></div><br><div>    <span style="color:rgb(0,73,176);font-weight:bold">def </span><span style="color:rgb(191,38,0);font-weight:bold">_NH_SIPEngineLog</span>(<span style="color:rgb(9,30,66);font-weight:bold">self</span>, <span style="color:rgb(32,32,32)">notification</span>):</div></div><div><span style="background-color:rgb(255,255,254);color:rgb(0,0,0);font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-size:13px;white-space:pre">        </span><span style="background-color:rgb(255,255,254);font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-size:13px;white-space:pre;color:rgb(9,30,66);font-weight:bold">print</span><span style="background-color:rgb(255,255,254);color:rgb(0,0,0);font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-size:13px;white-space:pre"> </span><span style="background-color:rgb(255,255,254);font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-size:13px;white-space:pre;color:rgb(9,101,69)">'got a log!'</span> <br></div></div></div></div>