Virtual number with Find-Me and Follow-Me service is getting popular. The idea is you can give your friends and family a virtual number. Then you can register multiple phones, such as your cellphone, home phone, and work phone, to that virtual number. When people call your virtual number, the virtual number can ring your registered phones either one by one — Follow Me — or all at the same time — Find Me — until you pick up one of them.

In SIP world, your SIP address, e.g. sip:wchen@voxeo.com, essentially is the virtual number. You can register multiple SIP phones to your SIP address. To Find Me, simply proxy the call to all the registered addresses in parallel. To Follow Me, simply proxy the call to all the registered addresses sequentially.

In the Using SIP Servlet to implement SIP Registrar and Proxy Server blog, I described how registration and proxy works. With SIP Servlet, adding Find-Me and Follow-Me is trivial.

The following code was shown in that blog to demonstrate how SIP proxy works.

  @Override
  protected void doInvite(SipServletRequest req) throws ServletException, IOException {
    // application only has to worry about forwarding the initial request.
    // the rest is taken care by the container.
    if (req.isInitial()) {
      URI callee = req.getTo().getURI();
      Proxy proxy = req.getProxy();

      //let's see if the Location Service has bindings for this callee.
      List<URI> targets = _locator.getContacts(callee);
      if (targets.size() > 0) {
        // The Proxy Server should stay on the signaling path
        proxy.setRecordRoute(true);

        // Let the container handles all the 3xx redirect automatically
        proxy.setRecurse(true);

        // Try all the registered phones for this callee sequentially
        proxy.setParallel(false);

        //Yes, let's proxy the call to the registered phones.
        proxy.proxyTo(targets);
      }
      else {
        // Oops, no phone is registered right now. Let's do our best.
        proxy.proxyTo(callee);
      }
    }

When you have multiple phones registered, the above code essentially provides Follow-Me.

You can change one line — #19 –  to make this become Find-Me.

        proxy.setParallel(true);

What if you want to provide a PSTN virtual number and register PSTN numbers? SIP Servlet can work with either SIP URI and Telephone URL. So there is no difference as far as proxy code concerns. What you need is to connect the platform to a VoIP provider that can provide SIP-PSTN connectivity. In the future blog, I will show you how to configure Voxeo Prism to provide PSTN connectivity.

Originally from Voxeo Blogs