Java Phone Sample


The example shows you how to utilize our service using AcrossCommunications' Java Library.

It contains a set of classes for straight code writting without any additional knowledges about protocol used for data transmitting. Make sure that you have a licence key before using the library!

To build, deploy, and run the example you have to have:

  • Java 2 Platform, Standard Edition (J2SE) SDK 1.3.1 or higher.
  • AcrossCommunications' Java Library (available here)

Here is the simple phone client source code:

 
  package AcrossCommunication.Samples;
  import AcrossCommunication.ACProxies.*;
  public class LibPhoneClient{
      Personalizer pers = null;
      Session sess = null;
      public LibPhoneClient(String userName, String pwd) {
      try{
          pers = new Personalizer();
          sess = pers.CreateSession(userName, pwd);
      } catch(Exception exc){
          System.out.println("Initializing error.");
          System.out.println(exc);
      }
  }
  public static void main(String[] args) {
      LibPhoneClient client1 = new LibMailClient("user", "pwd");
      client1.SendPhoneMessageAndGetDigitResult();
  }
  
  public boolean SendPhoneMessageAndGetDigitResult(){
  boolean Result = false;
  if(sess == null){
      return false;
  }
  try{
      Phone p = sess.CreatePhoneNotification(true);
      p.Call("4161234567");
      p.Say("You have a meeting with the manager at 12.00, please press 1 to confirm the time.");
      String DigitResponse = p.WaitDigits(10, 1, "#");
      p.HangUp();
      p.Release();
      sess.Release();
      if( DigitResponse.compareTo("1")== 0 ){
          return true;
      }
      else{
          return false;
      }
  }
  catch (Exception ex){
      System.out.println("Internal exception during Send.. method!");
      System.out.println(ex);
      if(sess != null){
          try{
              sess.Release();
          }
           catch(Exception exc){
              System.out.println("Can't release session object!");
              System.out.println(exc);
          }
      }
      return false;
  }
  }

Also you can download this source code from here