Home Page RSMS/TAP v1.0 tm Component
Home
Help
RSms/Tap
Overview
Download & Try It
User Guide & Javadoc[TM] files
Pricing & Ordering
Other products
RSMS/UCP
Rfax
User Guide & Documentation
More information at the Javadoc[TM] pages (opens a new window).

Index

Introduction
   1) sendOneMessage()
   2) sendMessageList()
   3) sendMessage()
Logging

Introduction

There are three main classes that need to be used:

- TapSender, which includes several methods to send messages through the TAP protocol.

- ModemConnector, which establishes the communication channel to the remote server. You will need to create one ModemConnector object with the appropriate modem & communication parameters, and pass it to the TapSender object.

- SmsMessage. You will need to create an SmsMessage object for each SMS you wish to send, and pass them to any of the TapSender's sending methods.

You can send SMS messages by using three different TapSender methods:

1) TapSender.SendOneMessage()

^top

This is a simplified high level method that sends only one message. You have an example of its use in TapTestOne.java.

Here it is a sample code using the SendOneMessage() method.

CommConnector connector =

   new ModemConnector( "99999999", "", "COM99", 9600, 8, 1, 'N' );
SmsMessage message = new SmsMessage( "888888888", "RSMS/TAP One Message Test" ); TapSender sender = new TapSender( connector, "" );
if ( sender.sendOneMessage( message ) )

   System.out.println("Message Accepted.");

else {

   System.out.println("Message Could NOT be sent ! ");

   System.out.println("Reason : " + message.getStatusText() );

}

2) TapSender.SendMessageList()

^top

This is a high level method that sends any number of SMS in one connexion to the remote server. You should first prepare the messages in an ArrayList of SmsMessage objects. Then you will check each message status to know if it was accepted or not. You have an example of its use in TestTapMulti.java.

Sample code using the SendMessageList() method.


String recipient, text;

SmsMessage m;

ArrayList mlist = new ArrayList();



this.obtainSMSRecords();

while ( ! this.endOfRecords() ) {

   this.nextRecord();

   recipient = ...;

   text = ...;

   mlist.add( new SmsMessage( recipient, text ) );

   }



CommConnector connector =

   new ModemConnector( "99999999", "", "COM99", 9600, 8, 1, 'N' );
TapSender sender = new TapSender( connector, "" ); if ( sender.sendMessageList( mlist ) ) { for ( int i = 0; i < mlist.size(); i++ ) { m = (SmsMessage) mlist.get(i); if ( m.isAccepted() ) this.doAcceptedProcedure(m); else this.doRejectedProcedure(m); } } else { this.doErrorProcedure("Gateway Connexion failed at some point."); }

3) sendMessage()

^top

This is a low level method that requires you to open & close the connexion and to catch exceptions.

Sample code using the SendMessageList() method.


String recipient, text;

SmsMessage m;



CommConnector connector =

   new ModemConnector( "99999999", "", "COM99", 9600, 8, 1, 'N' );

TapSender sender = new TapSender( connector, "" );



this.obtainSMSRecords();



try {

   sender.open();



   while ( ! this.endOfRecords() ) {



      this.nextRecord();

      recipient = ...;

      text = ...;

      m = new SmsMessage( recipient, text ) );



      if ( sender.sendMessage( m ) )

         this.doAcceptedProcedure(m);

      else

         this.doRejectedProcedure(m);

   }



   sender.close();



} catch (IOException e) {

   this.doErrorProcedure(e);

}

Logging

^top

Logging is disabled by default. In order to enable logging you should use a com.java4less.util.Logger object.Both the ModemConnector and the TapSender classes can provide logging and you should enable them separately.

Sample code that enables logging:


connector.logger = Logger.getLogger("comm");

sender.logger = Logger.getLogger("tap");

By default logging is set to a medium ("info") level. To set it to the maximum detail just add:

connector.logger.setLevel( 7 );

sender.logger.setLevel( 7 );

By default logging is sent to System.err but of course you can change this.