<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Thanks for the information. I got something working today using
    sofia_contact, but am having issues with SIP registrations surviving
    for a good deal of time after the user has disconnected from the
    network.<br>
    <br>
    Basically, the SIP client is no longer available when the user
    leaves the building and is disconnected from Wifi.&nbsp; When this
    happens, sofia_contact continues to return a value indicating the
    client is registered for quite some time.<br>
    <br>
    I found the command "sofia profile &lt;profile_name&gt; check_sync",
    which I used successfully to invalidate registrations for users that
    have disconnected from the network. But I could not figure out how
    to make this execute before my "sofia_contact" condition in the
    dialplan. I am assuming this is because I need it to run before the
    ROUTING stage, and I can only get it to run in the EXECUTE stage.<br>
    <br>
    So I have a couple questions. Is check_sync quick enough to run on
    every inbound call prior to making routing decisions? Also,
    according to the comments here
    <a class="moz-txt-link-freetext" href="http://wiki.freeswitch.org/wiki/FS_weekly_2011_06_29">http://wiki.freeswitch.org/wiki/FS_weekly_2011_06_29</a> I should be
    able to give check_sync a user@domain argument, but this does not
    seem to work.<br>
    <br>
    Are there other ways to determine if a bridge failed because a
    user's SIP client was not reachable, versus a timeout or call
    rejection?<br>
    <br>
    Thanks for helping with this!<br>
    <br>
    -- Thaddeus<br>
    <br>
    On 5/4/2012 1:24 PM, Dave R. Kompel wrote:
    <blockquote cite="mid:20120504182445.9e296b96@mail.tritonwest.net"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <style>BODY{font:10pt Tahoma, Verdana, sans-serif}</style>
      <div>Thaddeus &amp; Michael:</div>
      <div>&nbsp;</div>
      <div>As&nbsp; Michael stated there are many ways to fail over if a
        phone/user isn't registered. However sometimes you may want to
        actually check the registration yourself. Or even do something
        based on&nbsp;a contact being registered, that has nothing to do with
        the actual one you are calling.</div>
      <div>&nbsp;</div>
      <div>I normally use the API:
        sofia_contact([profile/]&lt;user&gt;@domain). It returns the
        channel string you would pass to bridge. If the user isn't
        registered it returns "error/&lt;the error&gt;" so it would use
        the logical "error" endpoint to handle the right treatment. If
        the regex "^error" match is true, then the user isn't
        registered. </div>
      <div>&nbsp;</div>
      <div>The extra thing you get from that API call is that you can
        use a "*" for the profile, and find out which SIP profile the
        user is registered in. For example in the case of an Android
        client, that may be using WIFI or 3G, and you have an external
        and internal profile they can register, you can tell if the user
        is "on site" or "off site" by the profile it returns, and can be
        more restrictive of the calls you send to someone when they're
        out of the office.</div>
      <div>&nbsp;</div>
      <div>--Dave</div>
      <br>
      <blockquote style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT:
        5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
        <hr>
        <b>From:</b> Michael Collins [<a class="moz-txt-link-freetext" href="mailto:msc@freeswitch.org">mailto:msc@freeswitch.org</a>]<br>
        <b>To:</b> FreeSWITCH Users Help
        [<a class="moz-txt-link-freetext" href="mailto:freeswitch-users@lists.freeswitch.org">mailto:freeswitch-users@lists.freeswitch.org</a>]<br>
        <b>Sent:</b> Fri, 04 May 2012 10:34:31 -0700<br>
        <b>Subject:</b> Re: [Freeswitch-users] Dialplan condition to
        test if SIP client is registered<br>
        <br>
        Hi Thaddeus,<br>
        <br>
        You definitely have several options here. While you could use
        the sofia_contact API, I'm wondering if perhaps you could let
        the dialplan and the bridge app do the work for you.<br>
        <br>
        You could bridge directly to the Android user and then if it
        fails it could then continue in the dialplan and ring the mobile
        number. This is covered briefly on the <a
          moz-do-not-send="true"
href="http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_bridge#Implementing_Failover">wiki</a>,
        however &lt;shameless_plug&gt;it is covered very nicely in the
        new FreeSWITCH Cookbook&lt;/shameless_plug&gt; in chapter 1.<br>
        <br>
        Try out the basic failover (pipe-separated list of endpoints)
        and if that doesn't work let us know. Maybe you could hop on IRC
        and talk live with other community members. Of course, it can't
        hurt to raise your karma by getting the FreeSWITCH books. :)
        (See <a moz-do-not-send="true" href="http://freeswitch.org/">freeswitch.org</a>,
        upper left corner.)<br>
        <br>
        Thanks,<br>
        Michael<br>
        <br>
        <div class="gmail_quote">On Fri, May 4, 2012 at 10:10 AM, <a
            moz-do-not-send="true" href="mailto:thaddeus@thogan.com">thaddeus@thogan.com</a>
          <span>&lt;<a moz-do-not-send="true"
              href="mailto:thaddeus@thogan.com">thaddeus@thogan.com</a>&gt;</span>
          wrote:<br>
          <blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px
            0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">I was
            wondering if there is a way to tell if a SIP client is
            registered with a dialplan condition? Or maybe a better way
            to accomplish the following?:<br>
            <br>
            The users' cell phones (Android) are running a SIP client
            and connect to freeswitch via Wifi when in the office. I
            want calls destined for a given user to ring only their
            extension if they are connected via SIP, and ring only their
            mobile number when they are not connected.<br>
            <br>
            Currently I just take every incoming call and bridge it back
            out to their mobile number, but 95% of the time these users
            are on the Wifi network, and I could just pass the call to
            their phones via SIP.<br>
            <br>
            I have tested hunt groups but the callers hear ringing for
            far too long. Ring groups don't work because it is confusing
            when the user simultaneously receiving the same call via SIP
            and mobile on the same phone.<br>
            <br>
            Thanks in advance for any insights and help!<span
              class="HOEnZb"><font color="#888888"><br>
                <br>
                -- Thaddeus </font></span><br>
_________________________________________________________________________<br>
            Professional FreeSWITCH Consulting Services:<br>
            <a moz-do-not-send="true"
              href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
            <a moz-do-not-send="true"
              href="http://www.freeswitchsolutions.com/">http://www.freeswitchsolutions.com</a><br>
            <br>
            FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
            <a moz-do-not-send="true" href="http://www.cudatel.com/">http://www.cudatel.com</a><br>
            <br>
            Official FreeSWITCH Sites<br>
            <a moz-do-not-send="true" href="http://www.freeswitch.org/">http://www.freeswitch.org</a><br>
            <a moz-do-not-send="true" href="http://wiki.freeswitch.org/">http://wiki.freeswitch.org</a><br>
            <a moz-do-not-send="true" href="http://www.cluecon.com/">http://www.cluecon.com</a><br>
            <br>
            FreeSWITCH-users mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
            UNSUBSCRIBE:<a moz-do-not-send="true"
              href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
            <a moz-do-not-send="true" href="http://www.freeswitch.org/">http://www.freeswitch.org</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </blockquote>
      <style>
</style>
      <div>&nbsp;</div>
      <div>&nbsp;</div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_________________________________________________________________________
Professional FreeSWITCH Consulting Services:
<a class="moz-txt-link-abbreviated" href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a>

FreeSWITCH-powered IP PBX: The CudaTel Communication Server
<a class="moz-txt-link-freetext" href="http://www.cudatel.com">http://www.cudatel.com</a>

Official FreeSWITCH Sites
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://wiki.freeswitch.org">http://wiki.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://www.cluecon.com">http://www.cluecon.com</a>

FreeSWITCH-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>