<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hello,</p>
    <p>$expires(min) can be used to see if there is an unregistration
      going on:</p>
    <p>  -
<a class="moz-txt-link-freetext" href="https://www.kamailio.org/wiki/cookbooks/4.4.x/pseudovariables#expires_key_-_expires_values">https://www.kamailio.org/wiki/cookbooks/4.4.x/pseudovariables#expires_key_-_expires_values</a></p>
    <p>It is more safe to use this variable because expire value can be
      either as Expires header or as parameter in Contact header.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 19/06/16 20:31, SamyGo wrote:<br>
    </div>
    <blockquote
cite="mid:CAJUJwtiWUs3NpAojiSBECQaiTbr9F1WiT5cgdsk-_e4ShnDfuA@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Alexandru,<br>
        <br>
        <div>The Expire header in Register can be your clue here. if it
          is greater than 0 means its a registration attempt. If the
          value is 0 then it is un-register request.</div>
        <div><br>
          This is how you can catch this.</div>
        <div><br>
        </div>
        <div><font face="monospace, monospace">if(is_method("REGISTER")
             ) {</font></div>
        <div><font face="monospace, monospace"> if($hdr(Expire) == 0) {</font></div>
        <div><font face="monospace, monospace"> // Un-Registering User
            $fU</font></div>
        <div><font face="monospace, monospace"> } else {<br>
             // Register request<br>
             } </font></div>
        <div><font face="monospace, monospace">}</font></div>
        <div><br>
        </div>
        <div>I'd say put it somewhere just before the save("lcoation");
          line.</div>
        <div><br>
        </div>
        <div>The event for contact-expired will work for a user when its
          expires timer exceeds and there is no registration refresh
          from the device and hence Kamailio removes the contact from
          usrloc records.</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Regards,</div>
        <div>Sammy</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Sun, Jun 19, 2016 at 1:41 PM,
          Alexandru Covalschi <span dir="ltr"><<a
              moz-do-not-send="true" href="mailto:568691@gmail.com"
              target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:568691@gmail.com">568691@gmail.com</a></a>></span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Hello list,<br>
              <br>
              I need to send to an external API events when user is
              registrated and de-registrated.<br>
              As far as I understand standart behaviour is as follows:<br>
              <br>
              If user is not registered, he sends REGISTER and he is
              registrated (I can catch that because I make the auth).<br>
              If user is registered and sends REGISTER he is
              de-register. <br>
              (Please correct me if I'm wrong.)<br>
              How can I catch that? <br>
              Can I use event_route[usrloc:contact-expired]?<br>
              <br>
              Thanks in advance!<span class="HOEnZb"><font
                  color="#888888"><br clear="all">
                  <div><br>
                  </div>
                  -- <br>
                  <div data-smartmail="gmail_signature">
                    <div dir="ltr">
                      <div>
                        <div dir="ltr">Alexandru Covalschi<br>
                          ABRISS-Solutions
                          <div>VoIP engineer and system administrator<br>
                            tel: <a moz-do-not-send="true"
                              href="tel:%2B37367398493"
                              value="+37367398493" target="_blank">+37367398493</a><br>
                            web: <a moz-do-not-send="true"
                              href="http://abs-telecom.com/"
                              target="_blank">http://abriss.solutions/</a></div>
                        </div>
                      </div>
                    </div>
                  </div>
                </font></span></div>
            <br>
            _______________________________________________<br>
            SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
            mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users"
              rel="noreferrer" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a> - <a class="moz-txt-link-freetext" href="http://www.kamailio.org">http://www.kamailio.org</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
  </body>
</html>