org.jsmpp.examples.gateway
Class AutoReconnectGateway

java.lang.Object
  extended by org.jsmpp.examples.gateway.AutoReconnectGateway
All Implemented Interfaces:
Gateway

public class AutoReconnectGateway
extends java.lang.Object
implements Gateway

This are implementation of Gateway. This gateway will reconnect for a specified interval if the session are closed.

Author:
uudashr

Nested Class Summary
private  class AutoReconnectGateway.SessionStateListenerImpl
          This class will receive the notification from SMPPSession for the state changes.
 
Field Summary
private  BindParameter bindParam
           
private static org.slf4j.Logger logger
           
private  long reconnectInterval
           
private  java.lang.String remoteIpAddress
           
private  int remotePort
           
private  SMPPSession session
           
 
Constructor Summary
AutoReconnectGateway(java.lang.String remoteIpAddress, int remotePort, BindParameter bindParam)
          Construct auto reconnect gateway with specified ip address, port and SMPP Bind parameters.
 
Method Summary
private  SMPPSession getSession()
          Get the session.
static void main(java.lang.String[] args)
           
private  SMPPSession newSession()
          Create new SMPPSession complete with the AutoReconnectGateway.SessionStateListenerImpl.
private  void reconnectAfter(long timeInMillis)
          Reconnect session after specified interval.
 java.lang.String submitShortMessage(java.lang.String serviceType, TypeOfNumber sourceAddrTon, NumberingPlanIndicator sourceAddrNpi, java.lang.String sourceAddr, TypeOfNumber destAddrTon, NumberingPlanIndicator destAddrNpi, java.lang.String destinationAddr, ESMClass esmClass, byte protocolId, byte priorityFlag, java.lang.String scheduleDeliveryTime, java.lang.String validityPeriod, RegisteredDelivery registeredDelivery, byte replaceIfPresentFlag, DataCoding dataCoding, byte smDefaultMsgId, byte[] shortMessage, OptionalParameter... optionalParameters)
          Submit the short message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.slf4j.Logger logger

session

private SMPPSession session

remoteIpAddress

private java.lang.String remoteIpAddress

remotePort

private int remotePort

bindParam

private BindParameter bindParam

reconnectInterval

private long reconnectInterval
Constructor Detail

AutoReconnectGateway

public AutoReconnectGateway(java.lang.String remoteIpAddress,
                            int remotePort,
                            BindParameter bindParam)
                     throws java.io.IOException
Construct auto reconnect gateway with specified ip address, port and SMPP Bind parameters.

Parameters:
remoteIpAddress - is the SMSC IP address.
remotePort - is the SMSC port.
bindParam - is the SMPP Bind parameters.
Throws:
java.io.IOException
Method Detail

submitShortMessage

public java.lang.String submitShortMessage(java.lang.String serviceType,
                                           TypeOfNumber sourceAddrTon,
                                           NumberingPlanIndicator sourceAddrNpi,
                                           java.lang.String sourceAddr,
                                           TypeOfNumber destAddrTon,
                                           NumberingPlanIndicator destAddrNpi,
                                           java.lang.String destinationAddr,
                                           ESMClass esmClass,
                                           byte protocolId,
                                           byte priorityFlag,
                                           java.lang.String scheduleDeliveryTime,
                                           java.lang.String validityPeriod,
                                           RegisteredDelivery registeredDelivery,
                                           byte replaceIfPresentFlag,
                                           DataCoding dataCoding,
                                           byte smDefaultMsgId,
                                           byte[] shortMessage,
                                           OptionalParameter... optionalParameters)
                                    throws PDUException,
                                           ResponseTimeoutException,
                                           InvalidResponseException,
                                           NegativeResponseException,
                                           java.io.IOException
Description copied from interface: Gateway
Submit the short message. It has the same parameter as SMPPSession.submitShortMessage(String, TypeOfNumber, NumberingPlanIndicator, String, TypeOfNumber, NumberingPlanIndicator, String, ESMClass, byte, byte, String, String, RegisteredDelivery, byte, DataCoding, byte, byte[], OptionalParameter...).

Specified by:
submitShortMessage in interface Gateway
Returns:
Throws:
PDUException
ResponseTimeoutException
InvalidResponseException
NegativeResponseException
java.io.IOException

newSession

private SMPPSession newSession()
                        throws java.io.IOException
Create new SMPPSession complete with the AutoReconnectGateway.SessionStateListenerImpl.

Returns:
the SMPPSession.
Throws:
java.io.IOException - if the creation of new session failed.

getSession

private SMPPSession getSession()
                        throws java.io.IOException
Get the session. If the session still null or not in bound state, then IO exception will be thrown.

Returns:
the valid session.
Throws:
java.io.IOException - if there is no valid session or session creation is invalid.

reconnectAfter

private void reconnectAfter(long timeInMillis)
Reconnect session after specified interval.

Parameters:
timeInMillis - is the interval.

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException