Thaddeus & Michael:
As 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 a contact being registered, that has nothing to do with the actual one you are calling.
I normally use the API: sofia_contact([profile/]<user>@domain). It returns the channel string you would pass to bridge. If the user isn't registered it returns "error/<the error>" 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.
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.
--Dave
From: Michael Collins [mailto:msc@freeswitch.org]
To: FreeSWITCH Users Help [mailto:freeswitch-users@lists.freeswitch.org]
Sent: Fri, 04 May 2012 10:34:31 -0700
Subject: Re: [Freeswitch-users] Dialplan condition to test if SIP client is registered
Hi Thaddeus,
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.
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 wiki, however <shameless_plug>it is covered very nicely in the new FreeSWITCH Cookbook</shameless_plug> in chapter 1.
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 freeswitch.org, upper left corner.)
Thanks,
Michael