Experts in SMS and MMS Technology. NCLs Provato is an SMS/MMS Gateway supporting  WAP Push, EMS, MMS, SMS, Nokia Smart Messaging, SMPP, CIMD, UCP, MM7, M20, TC35 NCL Technologies Ltd
Provato - SMS MMS Gateway
Mobile Messaging in J2EE & .NET

SwiftNote - Java SMS Toolkit

ie.ncl.sms.cimd
Class CimdConnection

java.lang.Object
  extended by ie.ncl.msg.impl.SimpleConnection
      extended by ie.ncl.sms.cimd.CimdConnection
All Implemented Interfaces:
AttributeNames, Connection, Receiver, Sender, MessageAttributeNames

public class CimdConnection
extends ie.ncl.msg.impl.SimpleConnection
implements Sender, Receiver, MessageAttributeNames

The CimdConnection class is an implementation of the CIMD 2.0 Protocol used to connect to a CIMD compliant Short Message Service Centre, for the purposes of sending and receiving text and binary short messages.

IMPORTANT: Unless you are performing some CIMD specific operation it is best to use the ie.ncl.msg.Factory class to create instances of the CimdConnection. This allows you to dynamically create transport independent software applications.

Note the CIMD protocol now supports the CC parameter.

The Factory properties used in the CIMD Connection configuration are:-

NAME VALUE DEFAULT    
class The name of the implementing class - ie.ncl.sms.cimd.CimdConnection mandatory
id Login user id  (string) mandatory 
pass Login password (string) mandatory 
host Host name of the SMSC (string)  mandatory 
port IP port number of the CIMD Server  (number) mandatory 
sendRequestDelivery Send a request to deliver messages on connection (true or false) optional - defaults to false
ignoreReceipts Ignore delivery receipts (true or false) optional - defaults to false
linkAliveIfAnyDataReceived The link is alive if any data is received within the response timeout of sending a query link operation to the SMSC. If this is false, the query link response must be received within the timeout (true or false) optional - defaults to true
smscResponseTimeoutSeconds The response timeout for which a response must be received from the SMSC upon sending a request (number of seconds). optional - defaults to 60 seconds.
unackedQueueSize The maximum number of outstanding requests sent to the SMSC without have receive a response for any (number) optional - defaults to one request
reconnectOnDisconnect Reconnect to the SMSC if the connection is dropped (true or false). optional - defaults to true
.reconnectRetryAttempts The number of re-connection retry attempts to be performed if a connection is lost (number). optional - defaults to 60 retries
reconnectTimerSeconds The number of seconds between re-connection attempts (number of seconds)  optional -defaults to 60 seconds
queryLinkEverySeconds Query the link every so often to ensure it is up and running (number of seconds) optional - defaults to 30 seconds
statusReportValueForRegisteredMessages This is the value placed in the status report request CIMD field when a message is sent. optional - defaults to 62 i.e. report for success or failure
windowSize This numerical value is the value placed in the Window Size login parameter. This has no behavioural effect in the software implementation of the CIMD protocol. optional - defaults to window size parameter being sent
pingOnlyWhenUnackedQueueSizeZero If true, a query link will not be sent while there are unacknowledged messages. Some CIMD SMSCs "complain" if a ping is sent while there is a pending submit acknowledgment. optional - defaults false
sourceAddressParameter Specifies the CIMD source address parameter which can be 23 for Numeric, 27 for Alphanumeric, or 0 in which case the CIMD layer will work it out automatically (if it detects any character not a digit or + then it will use ASCII/27) optional - defaults to 0/automatic

See Also:
Factory

Field Summary
 
Fields inherited from interface ie.ncl.msg.Connection
CONNECTED, NOT_CONNECTED, NOT_USED, RECONNECTING
 
Fields inherited from interface ie.ncl.sms.MessageAttributeNames
CC, DCS, EOT_GSM_ESCAPE_CHARACTER, PID, PRIORITY, RECEIPT, RECEIPT_BYTES, RECEIPT_STATUS, RECEIPT_TEXT, REGISTERED, REPLACE, REPLY_PATH, SCA, SCHEDULE, SUBMIT_ERROR, TIMESTAMP, UDH, UDHI, VALIDITY
 
Constructor Summary
CimdConnection()
           
 
Method Summary
 void acknowledge(Message m, boolean positive)
          Not implemented - acknowledgements are automatic.
 void close()
          Close the CIMD connection.
 void connect()
          Make a CIMD connection.
 int getFlowControlTimer()
          The flow control timer is used to specify the duration between receiving a 'slow down' indication from the SMSC and starting to send messages again.
 boolean getIgnoreReceipts()
          This is used to specify that delivery reports of messages are to be ignored.
 boolean getLinkAliveIfAnyDataReceived()
          Get the Link Alive functionality.
 java.lang.String getPassword()
          Get the Password required to connect and login to the CIMD server.
 int getQueryLinkTimer()
          The query link timer specifies how often a link alive check is performed with the SMSC.
 boolean getReconnectOnDisconnect()
          Reconnect if there is a disconnection.
 int getReconnectRetryAttempts()
          This is used to specify the maximum number of reconnection retry attempts when a link has gone down or stops responding.
 long getReconnectTimer()
          This is used to specify time duration between reconnection retry attempts when a link has gone down or stops responding.
 boolean getSendRequestDeliveryOnConnect()
          Send a request delivery on connection which tells the SMSC to deliver messages.
 int getSmscResponseTimeout()
          This is used to specify the maximum time that can elapse without receiving a response for a particular request.
 int getSourceAddressParameter()
          Gets the CIMD source parameter type - see properties above
 int getStatusReportValueForRegisteredMessages()
           
 int getUnackedQueueSize()
          This is used to specify the maximum number of unacknowledged requests.
 java.lang.String getUserId()
          Get the UserId required to connect and login to the CIMD server.
 int getWindowSize()
          Gets the CIMD window size login parameter.
 void init(java.util.Properties ps)
          Initialise the object with settings specified in the properties.
 boolean isAnotherPingAllowed()
           
 boolean isPingOnlyWhenUnackedQueueSizeZero()
           
 boolean isWindowSizeUsed()
          Determines if the CIMD window size login parameter is used i.e.
static void main(java.lang.String[] args)
          Print version information.
 void receive(ReceiverListener listener)
          Specify where received messages are sent.
 void send(Message message, SenderListener listener)
          Send a message asynchronously.
 void setFlowControlTimer(int i)
          The flow control timer is used to specify the duration between receiving a 'slow down' indication from the SMSC and starting to send messages again.
 void setHostPort(java.lang.String host, int port)
           
 void setIgnoreReceipts(boolean b)
          This is used to specify that delivery reports of messages are to be ignored.
 void setLinkAliveIfAnyDataReceived(boolean newVal)
          Set the Link Alive functionality.
 void setPingOnlyWhenUnackedQueueSizeZero(boolean pingOnlyWhenUnackedQueueSizeZero)
           
 void setQueryLinkTimer(int i)
          The query link timer specifies how often a link alive check is performed with the SMSC.
 void setReceiverListener(ReceiverListener listener)
          Specify where received messages are sent.
 void setReconnectOnDisconnect(boolean yesOrNo)
          Reconnect if there is a disconnection.
 void setReconnectRetryAttempts(int numberOfTimes)
          This is used to specify the maximum number of reconnection retry attempts when a link has gone down or stops responding.
 void setReconnectTimer(int usecs)
          This is used to specify time duration between reconnection retry attempts when a link has gone down or stops responding.
 void setSendRequestDeliveryOnConnect(boolean yesOrNo)
          Send a request delivery on connection which tells the SMSC to deliver messages.
 void setSmscResponseTimeout(int usec)
          This is used to specify the maximum time that can elapse without receiving a response for a particular request.
 void setSourceAddressParameter(int sourceAddressParameter)
          Sets the CIMD source parameter type - see properties above.
 void setUnackedQueueSize(int size)
          This is used to specify the maximum number of unacknowledged requests.
 void setUser(java.lang.String userId, java.lang.String password)
          This sets the username and password required to login to the SMSC (or CIMD Server).
 void setWindowSize(int windowSize)
          Sets the CIMD window size login parameter.
 void shutdown()
          Shutdown the connection.
 
Methods inherited from class ie.ncl.msg.impl.SimpleConnection
connected, getConnectionStatus, getErrorListener, getName, getTypeDefaults, init, mergeDefaultAttributes, putTypeDefaults, setErrorListener, setName
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ie.ncl.msg.Connection
connected, getConnectionStatus, getTypeDefaults, init, putTypeDefaults, setErrorListener
 

Constructor Detail

CimdConnection

public CimdConnection()
Method Detail

setIgnoreReceipts

public void setIgnoreReceipts(boolean b)
This is used to specify that delivery reports of messages are to be ignored.


getIgnoreReceipts

public boolean getIgnoreReceipts()
This is used to specify that delivery reports of messages are to be ignored.


isPingOnlyWhenUnackedQueueSizeZero

public boolean isPingOnlyWhenUnackedQueueSizeZero()

setPingOnlyWhenUnackedQueueSizeZero

public void setPingOnlyWhenUnackedQueueSizeZero(boolean pingOnlyWhenUnackedQueueSizeZero)

isAnotherPingAllowed

public boolean isAnotherPingAllowed()

getWindowSize

public int getWindowSize()
Gets the CIMD window size login parameter.

Returns:
window size

setWindowSize

public void setWindowSize(int windowSize)
Sets the CIMD window size login parameter.


isWindowSizeUsed

public boolean isWindowSizeUsed()
Determines if the CIMD window size login parameter is used i.e. non zero. If non-zero, the value is transmitted to the server during login.


setSmscResponseTimeout

public void setSmscResponseTimeout(int usec)
This is used to specify the maximum time that can elapse without receiving a response for a particular request. If a response is not furnished by the SMSC then the link is dropped. An attempt will be made to re-establish the link if the reconnectOnDisconnect is turned on.

See Also:
setReconnectOnDisconnect(boolean)

getSmscResponseTimeout

public int getSmscResponseTimeout()
This is used to specify the maximum time that can elapse without receiving a response for a particular request. If a response is not furnished by the SMSC then the link is dropped. An attempt will be made to re-establish the link if the reconnectOnDisconnect is turned on.

See Also:
setReconnectOnDisconnect(boolean)

getReconnectOnDisconnect

public boolean getReconnectOnDisconnect()
Reconnect if there is a disconnection.

See Also:
setReconnectRetryAttempts(int), setReconnectTimer(int), getReconnectRetryAttempts(), getReconnectTimer()

setReconnectOnDisconnect

public void setReconnectOnDisconnect(boolean yesOrNo)
Reconnect if there is a disconnection.

See Also:
setReconnectRetryAttempts(int), setReconnectTimer(int), getReconnectRetryAttempts(), getReconnectTimer()

getStatusReportValueForRegisteredMessages

public int getStatusReportValueForRegisteredMessages()

getSendRequestDeliveryOnConnect

public boolean getSendRequestDeliveryOnConnect()
Send a request delivery on connection which tells the SMSC to deliver messages. This is false by default and may be pre-configured on the SMSC (i.e. the SMSC may do this anyway).

See Also:
setSendRequestDeliveryOnConnect(boolean)

setSendRequestDeliveryOnConnect

public void setSendRequestDeliveryOnConnect(boolean yesOrNo)
Send a request delivery on connection which tells the SMSC to deliver messages. This is false by default and may be pre-configured on the SMSC (i.e. the SMSC may do this anyway).

See Also:
getSendRequestDeliveryOnConnect()

getSourceAddressParameter

public int getSourceAddressParameter()
Gets the CIMD source parameter type - see properties above


setSourceAddressParameter

public void setSourceAddressParameter(int sourceAddressParameter)
Sets the CIMD source parameter type - see properties above. If it is not one of 0,23 or 27 it will set to 0


setReconnectRetryAttempts

public void setReconnectRetryAttempts(int numberOfTimes)
This is used to specify the maximum number of reconnection retry attempts when a link has gone down or stops responding. This is only relevant if reconnectOnDisconnect is turned on.

See Also:
setReconnectOnDisconnect(boolean), setReconnectTimer(int), getReconnectOnDisconnect(), getReconnectTimer()

getReconnectRetryAttempts

public int getReconnectRetryAttempts()
This is used to specify the maximum number of reconnection retry attempts when a link has gone down or stops responding. This is only relevant if reconnectOnDisconnect is turned on.

See Also:
setReconnectOnDisconnect(boolean), setReconnectTimer(int), getReconnectOnDisconnect(), getReconnectTimer()

setUnackedQueueSize

public void setUnackedQueueSize(int size)
This is used to specify the maximum number of unacknowledged requests.

See Also:
getUnackedQueueSize()

getUnackedQueueSize

public int getUnackedQueueSize()
This is used to specify the maximum number of unacknowledged requests.

See Also:
setUnackedQueueSize(int)

setReconnectTimer

public void setReconnectTimer(int usecs)
This is used to specify time duration between reconnection retry attempts when a link has gone down or stops responding. This is only relevant if reconnectOnDisconnect is turned on.

See Also:
setReconnectOnDisconnect(boolean), setReconnectTimer(int), getReconnectOnDisconnect(), getReconnectTimer()

getReconnectTimer

public long getReconnectTimer()
This is used to specify time duration between reconnection retry attempts when a link has gone down or stops responding. This is only relevant if reconnectOnDisconnect is turned on.

See Also:
setReconnectOnDisconnect(boolean), setReconnectTimer(int), getReconnectOnDisconnect(), getReconnectTimer()

getLinkAliveIfAnyDataReceived

public boolean getLinkAliveIfAnyDataReceived()
Get the Link Alive functionality. If this is true, then the link is up and running if ANY data has been received within the response time of a query link request. If this is false, then the link is alive IF AND ONLY IF a query link response is received within the response time (set getSmscResonseTimeout) of a query link request. Applications sending a high through put of messages asynchronously may have a large number of out standing messages which take time to process. As such, the SMSC may be responding properly but may not have processed all message responses in time before sending a query link response back to the application.


setLinkAliveIfAnyDataReceived

public void setLinkAliveIfAnyDataReceived(boolean newVal)
Set the Link Alive functionality.

See Also:
getLinkAliveIfAnyDataReceived()

receive

public void receive(ReceiverListener listener)
             throws ConnectionException
Specify where received messages are sent.

Specified by:
receive in interface Receiver
Throws:
ConnectionException
See Also:
Message

setReceiverListener

public void setReceiverListener(ReceiverListener listener)
                         throws ConnectionException
Specify where received messages are sent.

Specified by:
setReceiverListener in interface Receiver
Throws:
ConnectionException
See Also:
Message

acknowledge

public void acknowledge(Message m,
                        boolean positive)
                 throws ConnectionException,
                        MessageException
Not implemented - acknowledgements are automatic.

Specified by:
acknowledge in interface Receiver
Throws:
ConnectionException
MessageException

setUser

public void setUser(java.lang.String userId,
                    java.lang.String password)
This sets the username and password required to login to the SMSC (or CIMD Server). This should be specified before connecting.

See Also:
getUserId(), getPassword(), connect()

getUserId

public java.lang.String getUserId()
Get the UserId required to connect and login to the CIMD server.

See Also:
setUser(java.lang.String, java.lang.String)

getPassword

public java.lang.String getPassword()
Get the Password required to connect and login to the CIMD server.

See Also:
setUser(java.lang.String, java.lang.String)

main

public static void main(java.lang.String[] args)
Print version information.


setHostPort

public void setHostPort(java.lang.String host,
                        int port)

getQueryLinkTimer

public int getQueryLinkTimer()
The query link timer specifies how often a link alive check is performed with the SMSC. The link is assumed to be 'dead' if no response is received within the SMSC Response Timeout. If a dead link is detected then a reconnection may be re-established if the 'ReconnectOnDisconnect' flag is set, otherwise an exception will be thrown to the calling.

See Also:
getSmscResponseTimeout(), getReconnectOnDisconnect(), getLinkAliveIfAnyDataReceived()

setQueryLinkTimer

public void setQueryLinkTimer(int i)
The query link timer specifies how often a link alive check is performed with the SMSC. The link is assumed to be 'dead' if no response is received within the SMSC Response Timeout. If a dead link is detected then a reconnection may be re-established if the 'ReconnectOnDisconnect' flag is set, otherwise an exception will be thrown to the calling.

See Also:
getSmscResponseTimeout(), getReconnectOnDisconnect(), getLinkAliveIfAnyDataReceived()

getFlowControlTimer

public int getFlowControlTimer()
The flow control timer is used to specify the duration between receiving a 'slow down' indication from the SMSC and starting to send messages again. This is currently not used for CIMD.

See Also:
setFlowControlTimer(int)

setFlowControlTimer

public void setFlowControlTimer(int i)
The flow control timer is used to specify the duration between receiving a 'slow down' indication from the SMSC and starting to send messages again. This is currently not used for CIMD.

See Also:
getFlowControlTimer()

shutdown

public void shutdown()
Description copied from interface: Connection
Shutdown the connection. This is used to shutdown a connection ungracefully.

Specified by:
shutdown in interface Connection

connect

public void connect()
             throws ConnectionException
Make a CIMD connection. Various settings such as the user id and password should be set before the connection is established. All CIMD properties can be specified in the using the init method.

Specified by:
connect in interface Connection
Throws:
ConnectionException
See Also:
init(java.util.Properties)

init

public void init(java.util.Properties ps)
          throws ConnectionException
Description copied from interface: Connection
Initialise the object with settings specified in the properties. The properties will be implementation specific.

Specified by:
init in interface Connection
Throws:
ConnectionException

close

public void close()
Close the CIMD connection. If there are outstanding requests then these will be completed.

Specified by:
close in interface Connection
Specified by:
close in class ie.ncl.msg.impl.SimpleConnection

send

public void send(Message message,
                 SenderListener listener)
          throws MessageException,
                 ConnectionException
Description copied from interface: Sender
Send a message asynchronously. Once the message is processed (successfully sent or not) the listener will be called to notify the application of the outcome. See SenderListener for more detail.

Specified by:
send in interface Sender
Throws:
MessageException
ConnectionException
See Also:
SenderListener, Message

Experts in SMS and MMS Technology. NCLs Provato is an SMS/MMS Gateway supporting  WAP Push, EMS, MMS, SMS, Nokia Smart Messaging, SMPP, CIMD, UCP, MM7, M20, TC35 NCL Technologies Ltd
Provato - SMS MMS Gateway
Mobile Messaging in J2EE & .NET

SwiftNote - Java SMS Toolkit