<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hello Gertjan,</p>
<p>if you just want to monitor the dialog count of a user internally in your cfg, you don't need to use the presence modules. This can be done only with the dialog module with the functionality you already mentioned: dialog profiles. This will be also more
 acurate then querying the database table etc..<br>
</p>
<p>Cheers,</p>
<p>Henning<br>
</p>
<div class="moz-cite-prefix">Am 15.07.19 um 09:28 schrieb Gertjan Wolzak:<br>
</div>
<blockquote type="cite" cite="mid:916742622.40997.1563175704355.JavaMail.zimbra@kazlow.nl">
<div style="font-family: arial, helvetica, sans-serif; font-size:
        12pt; color: #000000">
<div><style><!--

@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}

p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.E-MailFormatvorlage18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style></div>
<div>Hello Henning,</div>
<div><br data-mce-bogus="1">
</div>
<div>Thank you for your time.</div>
<div><br data-mce-bogus="1">
</div>
<div>Think I have not been able to explain my challenge, or I am so far off, I need to start at zero.</div>
<div><br data-mce-bogus="1">
</div>
<div>I would want to only request the value of the in memory content, cause when I a call is finished, the records in the presentity table stay valid till they expire and the action to remove the expired records has been executed.</div>
<div><br data-mce-bogus="1">
</div>
<div>So to my best knowledge that would mean that even if the dialog has been ended, the record could exist for x amount of time depending on the min_expires and the clean_period parameters of the presence module.</div>
<div><br data-mce-bogus="1">
</div>
<div>For now I have solved my routing requirement by using the dialog funtions set_dlg_profile and get_profile_size. So I am able to limit calls to an extension that has an active call, but still allow outgoing calls from that extension.</div>
<div><br data-mce-bogus="1">
</div>
<div>I guess I have to look into doing something with the publish messages, get the information in those before the handle_publish action, retrieve the information and put it in a database table. But I think then the dialog option is the same, so just keep
 using that.</div>
<div><br data-mce-bogus="1">
</div>
<div>Am I correct in saying that  monitoring (realtime) if an extension is in a dialog can be checked by querying the presentity table, but that wont work to check if an extension is not in a call due to the expires value an dthe clean_period
</div>
<div>parameters. With extension I mean user..</div>
<div><br data-mce-bogus="1">
</div>
<div>Thank you.</div>
<div><br data-mce-bogus="1">
</div>
<div>Rgds,</div>
<div>Gertjan</div>
<div><br data-mce-bogus="1">
</div>
<div><br data-mce-bogus="1">
</div>
<div><br data-mce-bogus="1">
</div>
<div><br data-mce-bogus="1">
</div>
<div><br data-mce-bogus="1">
</div>
<div><br>
</div>
<hr id="zwchr" data-marker="__DIVIDER__">
<div data-marker="__HEADERS__"><b>From: </b>"Henning Westerholt" <a class="moz-txt-link-rfc2396E" href="mailto:hw@skalatan.de">
<hw@skalatan.de></a><br>
<b>To: </b>"sr-users" <a class="moz-txt-link-rfc2396E" href="mailto:sr-users@lists.kamailio.org">
<sr-users@lists.kamailio.org></a><br>
<b>Cc: </b>"Gertjan Wolzak" <a class="moz-txt-link-rfc2396E" href="mailto:g.wolzak@kazlow.nl">
<g.wolzak@kazlow.nl></a><br>
<b>Sent: </b>Friday, July 12, 2019 10:17:20 PM<br>
<b>Subject: </b>RE: Reading presence state<br>
</div>
<div><br>
</div>
<div data-marker="__QUOTED_TEXT__">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hello Gertjan,</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"> </span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US" lang="EN-GB">so you want to not only query the database, but also the in-memory content of the presence module?
</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US" lang="EN-GB"> </span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US" lang="EN-GB">The PV $subs does not work for you? Another idea – have you looked to the parameter subs_db_mode? From the docs:</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US" lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">“1 - Write-Through scheme. Subscriptions are updated synchronously in database and in memory(used for read operations). Use this scheme if speed is not top priority, but it's important that no subscriptions will be lost
 during crash or reboot or if you have an external application that reads the state of the subscriptions from database and they need to be updated synchronously.”</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">Cheers,</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">Henning</span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US" lang="EN-GB"> </span></p>
<div>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US" lang="EN-GB">-- </span>
</p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US" lang="EN-GB">Henning Westerholt -
</span><span style="mso-fareast-language:EN-US"><a href="https://skalatan.de/blog/" target="_blank" moz-do-not-send="true"><span style="color:#0563C1" lang="EN-GB">https://skalatan.de/blog/</span></a></span><span style="mso-fareast-language:EN-US" lang="EN-GB"></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US" lang="EN-GB">Kamailio services -
</span><span style="mso-fareast-language:EN-US"><a href="https://skalatan.de/services" target="_blank" moz-do-not-send="true"><span style="color:#0563C1" lang="EN-GB">https://skalatan.de/services</span></a></span><span style="mso-fareast-language:EN-US" lang="EN-GB"></span></p>
</div>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US" lang="EN-GB"> </span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1
                1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> sr-users <a class="moz-txt-link-rfc2396E" href="mailto:sr-users-bounces@lists.kamailio.org">
<sr-users-bounces@lists.kamailio.org></a> <b>On Behalf Of </b>Gertjan Wolzak<br>
<b>Sent:</b> Monday, July 8, 2019 2:23 PM<br>
<b>To:</b> sr-users <a class="moz-txt-link-rfc2396E" href="mailto:sr-users@lists.kamailio.org">
<sr-users@lists.kamailio.org></a><br>
<b>Subject:</b> [SR-Users] Reading presence state</p>
</div>
</div>
<p class="MsoNormal"> </p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black">Hello Kamailions,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black">I have been able to get the presence configured, subscribers see the status of their subscriptions, this is working fine, for internal, incoming external and external
 calls. This was solved by enabling use_pubruri_avps in the pua_dialoginfo module.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black">Now I want to be able to route calls based on the presence state. </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black">Using the presentity table could be used by doing a query based on the userpart of the ruri, which works fine when the call is still active, but it can take a while
 for the record to be removed from the presentity table, as that is dependend on the expires value. So when a query is made after a call is finished, a record would still be present in the presentity table till clean_period timer has hit again and the expires
 value is expired.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black">So I should get the status from memory, but I have not been able to find the information on how to do that.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black">Can someone enlighten me on where to find that information?</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black">Rgds,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Arial",sans-serif;color:black">Gertjan</span></p>
</div>
</div>
</div>
<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">-- 
Henning Westerholt - <a class="moz-txt-link-freetext" href="https://skalatan.de/blog/">https://skalatan.de/blog/</a>
Kamailio services - <a class="moz-txt-link-freetext" href="https://skalatan.de/services">https://skalatan.de/services</a></pre>
</body>
</html>