public class SmppSmsService extends AbstractSmsService implements SmsService, WindowingService, ManualAck
The message will be sent through a SMS Center (SMSC) reachable over a TCP/IP network connection
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BIND_RECEIVER
BIND_RECEIVER is the name of the constant holding the value "receiver"
|
static java.lang.String |
BIND_TRANSCEIVER
BIND_TRANSCEIVER is the name of the constant holding the value "transceiver"
|
static java.lang.String |
BIND_TRANSMITTER
BIND_TRANSMITTER is the name of the constant holding the value "transmitter"
|
static java.lang.String |
CFG_ADDR_NPI
CFG_ADDR_NPI is the name of the constant holding the value "smpp.addr.npi"
|
static java.lang.String |
CFG_ADDR_RANGE
CFG_ADDR_RANGE is the name of the constant holding the value "smpp.addr.range"
|
static java.lang.String |
CFG_ADDR_TON
CFG_ADDR_TON is the name of the constant holding the value "smpp.addr.ton"
|
static java.lang.String |
CFG_BIND_OPERATION
CFG_BIND_OPERATION is the name of the constant holding the value "smpp.bind.operation"
|
static java.lang.String |
CFG_DATA_CODING
CFG_DATA_CODING is the name of the constant holding the value "smpp.data.coding"
|
static java.lang.String |
CFG_ESCAPE_SPECIAL
CFG_ESCAPE_SPECIAL is the name of the constant holding the value "smpp.escape.special"
|
static java.lang.String |
CFG_GSM_PACKING
CFG_GSM_PACKING is the name of the constant holding the value "smpp.gsm.packing"
|
static java.lang.String |
CFG_ID_QUIRKS
CFG_ID_QUIRKS is the name of the constant holding the value "smpp.id.quirks"
|
static java.lang.String |
CFG_INTERFACE_VERSION
CFG_INTERFACE_VERSION is the name of the constant holding the value "smpp.interface.version"
|
static java.lang.String |
CFG_LOCAL_ADDRESS
CFG_LOCAL_ADDRESS is the name of the constant holding the value "smpp.local.address"
|
static java.lang.String |
CFG_LOGIN
CFG_LOGIN is the name of the constant holding the value "smpp.login"
|
static java.lang.String |
CFG_MSG_MODE
CFG_MSG_MODE is the name of the constant holding the value "smpp.message.mode"
|
static java.lang.String |
CFG_PASSWORD
CFG_PASSWORD is the name of the constant holding the value "smpp.password"
|
static java.lang.String |
CFG_SMSC_ADDRESS
CFG_SMSC_ADDRESS is the name of the constant holding the value "smpp.smsc.address"
|
static java.lang.String |
CFG_SMSC_CHARSET
CFG_SMSC_CHARSET is the name of the constant holding the value "smpp.smsc.charset"
|
static java.lang.String |
CFG_STATUS_FORMAT
CFG_STATUS_FMT is the name of the constant holding the value "smpp.status.format"
|
static java.lang.String |
CFG_SYSTEM_TYPE
CFG_SYSTEM_TYPE is the name of the constant holding the value "smpp.system.type"
|
static java.lang.String |
CFG_UNBIND_ON_IOE
CFG_UNBIND_ON_IOE is the name of the constant holding the value "smpp.unbind.on.ioe"
|
static java.lang.String |
CFG_WINDOW_SIZE
CFG_WINDOW_SIZE is the name of the constant holding the value "smpp.window.size".
|
static java.lang.String |
DEST_ADDR_SUBUNIT
DEST_ADDR_SUBUNIT is the name of the constant holding the
value "smpp.dest_addr_subunit"
|
static java.lang.String |
MSG_MODE_DEFAULT
MSG_MODE_DEFAULT is the name of the constant holding the value "Default"
|
static java.lang.String |
MSG_MODE_DGRAM
MSG_MODE_DGRAM is the name of the constant holding the value "Datagram"
|
static java.lang.String |
MSG_MODE_SAF
MSG_MODE_SAF is the name of the constant holding the value "StoreAndForward"
|
static java.lang.String |
MSG_MODE_TRX
MSG_MODE_TRX is the name of the constant holding the value "Transaction"
|
Constructor and Description |
---|
SmppSmsService()
Creates a new SmppSmsService.
|
Modifier and Type | Method and Description |
---|---|
void |
acknowledge(Message msg)
Accept a incoming message.
|
void |
acknowledge(Message msg,
java.lang.Object status)
Accept/reject a incoming message.
|
void |
cancel(Message msg)
Cancel a previously submitted message.
|
void |
connect()
Connect to the GSM device or SMS gateway.
|
void |
destroy()
Release allocated resources and destroy this service.
|
void |
disableManualAck()
Disable manual acknowledgement.
|
void |
disconnect()
Disconnect from the GSM device or SMS gateway.
|
void |
enableManualAck()
Enable manual acknowledgement.
|
int |
getNumberOfPendingMessages()
Returns the number of pending (unprocessed messages).
|
java.lang.String |
getServiceName()
Returns the name of the service.
|
int |
getWindowSize()
Returns the current window size or 1 if windowing is disabled.
|
boolean |
hasCapability(Capability cap)
Determine if a SMS Service has a specific capability.
|
void |
init(java.util.Properties props)
Initialize the SMPP service.
|
boolean |
isManualAckEnabled()
Check if manual acknowledgement is enabled/disabled.
|
SmppStatus |
query_sm(Message msg)
Query the Status of a previously submitted short message.
|
void |
query(Message msg)
Query the status of a previously submitted message.
|
void |
replace(Message oldMessage,
Message newMessage)
Replace a previously submitted message.
|
void |
sendMessage(Message message)
Send a message to a GSM recipient.
|
void |
setWindowSize(int size)
Set the window size for this service.
|
void |
startReceiving()
Start receiving Messages.
|
boolean |
supportReadMessage()
Deprecated.
since jSMS 2.1.8, use
hasCapability(Capability.RECEIVE)
instead. |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addMessageEventListener, getKeepAliveInterval, getLastIsAliveTime, getProperties, init, init, isAlive, isConnected, isInitialized, isKeepAliveActive, isReceiving, removeMessageEventListener, setKeepAliveInterval, stopReceiving, supportDeleteMessage
public static final java.lang.String CFG_SMSC_ADDRESS
public static final java.lang.String CFG_LOCAL_ADDRESS
public static final java.lang.String CFG_SYSTEM_TYPE
public static final java.lang.String CFG_INTERFACE_VERSION
public static final java.lang.String CFG_ADDR_TON
public static final java.lang.String CFG_ADDR_NPI
public static final java.lang.String CFG_ADDR_RANGE
public static final java.lang.String CFG_LOGIN
public static final java.lang.String CFG_PASSWORD
public static final java.lang.String CFG_BIND_OPERATION
public static final java.lang.String CFG_STATUS_FORMAT
public static final java.lang.String CFG_MSG_MODE
public static final java.lang.String CFG_WINDOW_SIZE
public static final java.lang.String CFG_SMSC_CHARSET
public static final java.lang.String CFG_ESCAPE_SPECIAL
public static final java.lang.String CFG_DATA_CODING
public static final java.lang.String CFG_GSM_PACKING
public static final java.lang.String CFG_ID_QUIRKS
public static final java.lang.String CFG_UNBIND_ON_IOE
public static final java.lang.String DEST_ADDR_SUBUNIT
public static final java.lang.String BIND_RECEIVER
public static final java.lang.String BIND_TRANSMITTER
public static final java.lang.String BIND_TRANSCEIVER
public static final java.lang.String MSG_MODE_DEFAULT
public static final java.lang.String MSG_MODE_SAF
public static final java.lang.String MSG_MODE_DGRAM
public static final java.lang.String MSG_MODE_TRX
public SmppSmsService()
init(Properties)
public void init(java.util.Properties props) throws MessageException
Initialize the SMPP service. The Properties object passed as argument to this method may contain the following properties:
Key | Value |
smpp.smsc.address | SMSC address in the format 'address:port ', e.g.
'smsc.xyz.org:1234 '
|
smpp.login | The SMPP system_id parameter is used to identify an ESME or an SMSC at bind time. An ESME system_id identifies the ESME or ESME agent to the SMSC. The SMSC system_id provides an identification of the SMSC to the ESME.SMPP System ID |
smpp.password |
The password parameter is used by the SMSC to authenticate the identity of
the binding ESME. The Service Provider may require ESME s to provide a password
when binding to the SMSC. This password is normally issued by the SMSC system
administrator. |
smpp.local.address | Local address to bind (format: address[:port]) Example:
192.168.1.1:5000 (if unset, the operation system
decides which address to use based on the SMSC host address). |
smpp.bind.operation | Type of BIND operation to use. Possible values are:
|
smpp.system.type | The system_type parameter is used to categorize the type of ESME that is binding to the SMSC. Examples include VMS (voice mail system) and OTA (over-the-air activation system). Specification of the system_type is optional - some SMSC s may not require ESME's to provide this detail. |
smpp.interface.version | This parameter is used to indicate the version of the SMPP
protocol. (Defaults to 0x34 )
|
smpp.addr.ton |
Indicates Type of Number of the ESME address. This parameter
will be used for the SMPP bind operation. If unset, the TON will
be set to NULL when binding to the SMSC. The following TON values
are defined:
|
smpp.addr.npi | Numbering Plan Indicator for ESME address. This parameter
will be used for the SMPP bind operation. If unset, the NPI will be
set to NULL when binding to the SMSC. The following NPI values are defined:
|
smpp.addr.range | The smpp.addr.range property is used in for connecting as receiver or transceiver to the SMSC. It specifies a set of SME addresses serviced by the ESME client. A single SME address may also be specified in the smpp.addr.range property. UNIX Regular Expression notation should be used to specify a range of addresses. Messages addressed to any destination in this range shall be routed to the ESME. |
smpp.keepalive.interval | Keepalive interval in seconds. Set to 0 to turn off keep-alive |
smpp.connector.timeout | Communication timeout in milliseconds |
smpp.message.mode | SMPP Message Mode to use ("Default", "StoreAndForward", "Datagram", "Transaction"). If unset, the default MC Mode will be used. |
smpp.status.format | Delivery Receipt format for SMPP Interface Version <= 0x34.
Use this property to specify the format of incoming delivery
receipts (Status Reports).
The default format is:"id:{0} sub:{1} dlvrd:{2} submit date:{3} done date:{4} stat:{5} err:{6} text:{7}"
|
smpp.smsc.charset | Character Set (Encoding) to use for communicating with the SMSC.
If unset, the default encoding of your VM will be used. If smpp.smsc.charset
is set to "GSM", jSMS will convert text messages to the GSM default 7 bit alphabet.
Contact your SMPP SMSC provider to ask for the correct encoding to use.
Example: By default, this property is unset (and therefore, the default encoding of your platform will be used). For more information about Java Character Encodings, have a look at the package specification of the package java.lang in the Java API-Docs of your JVM. |
smpp.data.coding | SMPP data_coding to use for text messages. If unset, jSMS uses the
GSM DCS (Data coding scheme) "as-is" for the data_coding field. If this property
is set, jSMS will encode the message class and the MWI indications as optional parameters
to the SMPP submit operation.
Consult your SMPP provider and the SMPP and GSM-03.38 specifications for more information about the DCS and data_coding parameters. By default, this property is unset. |
smpp.escape.special |
Specify if certain characters from the extended GSM alphabet should be
escaped using a "<ESC>char" sequence (e.g. the character '['
will be converted to '<ESC>('). This property has no influence
if the SMSC charset (smpp.smsc.charset ) is set to "GSM".
Default value: "true"
|
smpp.gsm.packing |
Specify if text messages should be 7-bit packed/unpacked.
Packing will only be done if the character set in use (smpp.smsc.charset)
is set to "GSM". Please note that packing will not be applied to
8-bit or Unicode (UCS) messages. Chances are high that you must
also set smpp.data.coding property to 0 (SMSC Default
Alphabet) to prevent your SMSC from converting the message. Default
value: "false".
|
smpp.id.quirks |
Most SMPP SMSC's return the ID for a sent message as an integer with
radix 10 and leading zeros, but for status reports, they use radix
16 (hex-values). If smpp.id.quirks is enabled (true), jSMS
tries to make sure that those IDs match by converting them to a
common base.
By default, this property is enabled. Set it to "false" to turn this feature off. |
smpp.dest_addr_subunit |
When this property is set to "true", jSMS converts the GSM Message
class for outgoing messages to the corresponding SMPP
"dest_addr_subunit" parameter.
By default, this property is "true". Set it to "false" to turn this feature off. |
smpp.unbind.on.ioe |
When this property is set to false , jSMS does not
issue an SMPP UNBIND operation if an I/O Exception
occurs while receiving data from the SMSC.
By default, this property is |
Notice: Properties in Italics are optional
init
in interface SmsService
MessageException
SmsService.init()
,
SmsService.init(java.io.File)
public void connect() throws MessageException, TimeoutException, SmppException
SmsService
MessageEvent.DEVICE_READY
event to all registered
MessageEventListeners.connect
in interface SmsService
MessageException
TimeoutException
SmppException
MessageEvent
,
MessageEventListener
public void disconnect() throws MessageException
SmsService
MessageEvent.DEVICE_NOT_READY
even to all
registered MessageEventListeners.disconnect
in interface SmsService
MessageException
MessageEvent
,
MessageEventListener
public void destroy()
SmsService
destroy
in interface SmsService
public final java.lang.String getServiceName()
SmsService
getServiceName
in interface SmsService
public void sendMessage(Message message) throws MessageException
SmsService
If the message to send is not a binary or unicode message, the
service will convert the message to the default GSM character set
using GsmHelper.iso2gsm()
.
This method will broadcast a MessageEvent
to all registered
MessageEventListener's. In case of success a MessageEvent
of type MESSAGE_SENT is broadcasted. Otherwise, the MessageEvent is of
type MESSAGE_NOT_SENT.
sendMessage
in interface SmsService
message
- the message to send.MessageException
- if the message could not be sent.public boolean supportReadMessage()
hasCapability(Capability.RECEIVE)
instead.SmsService
supportReadMessage
in interface SmsService
public void acknowledge(Message msg) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.io.IOException
ManualAck
acknowledge
in interface ManualAck
msg
- the Message to acceptjava.lang.IllegalArgumentException
- if the Message is null or not a incoming message,
or if the message has been received by another SmsService.java.lang.IllegalStateException
- if the Service is not initialized or not
connected to the SMSC.IOException
- if the communication with the SMSC fails.public void acknowledge(Message msg, java.lang.Object status) throws java.lang.IllegalArgumentException, java.lang.IllegalStateException, java.io.IOException
acknowledge
in interface ManualAck
msg
- the Message to acknowledgestatus
- an Integer holding the SMPP command_status or null to accept
the message.java.lang.IllegalArgumentException
- if the Message is null or not a incoming message,
or if the message has been received by another SmsService.java.lang.IllegalArgumentException
- if the status parameter is not an
instance of java.lang.Integerjava.lang.IllegalStateException
- if the Service is not initialized or not
connected to the SMSC.java.io.IOException
- if the communication with the SMSC fails.public void disableManualAck()
ManualAck
disableManualAck
in interface ManualAck
public void enableManualAck()
ManualAck
ManualAck.acknowledge(Message)
.enableManualAck
in interface ManualAck
public boolean isManualAckEnabled()
ManualAck
isManualAckEnabled
in interface ManualAck
public void startReceiving() throws java.io.IOException, java.lang.IllegalStateException
SmsService
MessageEventListener
with the Service. After receiving
has started, the service will broadcast a MessageEvent of type
MessageEvent.RECEIVING_STARTED
to all registered MessageEvent listeners.startReceiving
in interface SmsService
java.io.IOException
- if the communication with the SMS gateway/device failsjava.lang.IllegalStateException
- if the service isn't initialized and in connected
state or there are no registered Message Event Listeners.SmsService.addMessageEventListener(MessageEventListener)
public void setWindowSize(int size) throws java.lang.IllegalAccessException
WindowingService
setWindowSize
in interface WindowingService
size
- the window sizejava.lang.IllegalAccessException
- if the service is connected to
the SMSC when calling this methodpublic int getWindowSize()
WindowingService
getWindowSize
in interface WindowingService
public int getNumberOfPendingMessages()
WindowingService
getNumberOfPendingMessages
in interface WindowingService
public boolean hasCapability(Capability cap)
SmsService
hasCapability
in interface SmsService
cap
- one of the Constants in the Capability
class.public void query(Message msg) throws java.lang.UnsupportedOperationException, java.lang.IllegalStateException, MessageException
SmsService
MessageEvent
of
type STATUS_RECEIVED
.query
in interface SmsService
msg
- the previously submitted message.java.lang.UnsupportedOperationException
- if the service does not support
canceling messages.java.lang.IllegalStateException
- if the service is not initialized or not
connected to the SMSC.MessageException
- if querying the status failed.public SmppStatus query_sm(Message msg) throws java.lang.UnsupportedOperationException, java.lang.IllegalStateException, java.lang.IllegalArgumentException, MessageException
query(Message)
but immediately returns the Status
of the message instead of providing this information in the form of a
MessageEvent
. The message to query must contain at least the message
ID. If the sender address is set too, it will also be used in the
SMPP query_sm operation (fields source_addr_ton, source_addr_npi, source_addr).msg
- the previously sent messagejava.lang.UnsupportedOperationException
- if the service does not support
querying the message status.java.lang.IllegalStateException
- if the service is not initialized or not
connected to the SMSC.java.lang.IllegalArgumentException
- if the message is null or doesn't contain
a message ID.MessageException
- if querying the status failed.public void cancel(Message msg) throws java.lang.UnsupportedOperationException, java.lang.IllegalStateException, java.lang.IllegalArgumentException, MessageException
SmsService
status report
,
a MessageEvent
of type STATUS_RECEIVED
will be generated upon cancellation of the message.cancel
in interface SmsService
msg
- The previously sent messagejava.lang.UnsupportedOperationException
- if the service does not support
canceling messages.java.lang.IllegalStateException
- if the service is not initialized or not
connected to the SMSC.java.lang.IllegalArgumentException
- if the message is null or doesn't contain
the information required for cancelling the message (e.g. missing
message ID).MessageException
- if cancellation failed.public void replace(Message oldMessage, Message newMessage) throws java.lang.UnsupportedOperationException, java.lang.IllegalStateException, java.lang.IllegalArgumentException, MessageException
replace
in interface SmsService
oldMessage
- the previously sent message to replace.newMessage
- the replacement message.java.lang.UnsupportedOperationException
- if the service is not bound as
transceiver
or BIND_TRANSMITTER
.java.lang.IllegalStateException
- if the service is not initialized or not
connected to the SMSC.java.lang.IllegalArgumentException
- if the old- and/or new message is null or
the old message has no ID.MessageException
- if replacement failed.object XP, Inc. © 2000-2013. All rights reserved object XP