public class UcpSmsService extends AbstractSmsService implements SmsService, ManualAck, WindowingService
The message will be sent through a SMS Center (SMSC) reachable by either a modem/ISDN connection or TCP/IP.
Receiving Short messages via UCP is only supported for TCP/IP connections. UCP over TCP/IP requires a "large volume account" at the SMSC of your Mobile Network Provider. Contact your local provider for further information.
A special feature of UCP (only Operation 51) is, that message originator may be an alpha numerical String with maximal length of 16 characters.
For more information about the init-Properties supported by UcpSmsService, have a
look at this table
.
UcpMessage
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CFG_BPS
CFG_BPS is the name of the constant holding the value "ucp.port.bps".
|
static java.lang.String |
CFG_CONNECTOR
CFG_CONNECTOR is the name of the constant holding the value "ucp.connector".
|
static java.lang.String |
CFG_CONNECTOR_TIMEOUT
CFG_CONNECTOR_TIMEOUT is the name of the constant holding the value "ucp.connector.timeout".
|
static java.lang.String |
CFG_DATABITS
CFG_DATABITS is the name of the constant holding the value "ucp.port.databits".
|
static java.lang.String |
CFG_FLOWCTRL
CFG_FLOWCTRL is the name of the constant holding the value "ucp.port.flowcontrol".
|
static java.lang.String |
CFG_INITSTRING
CFG_INITSTRING is the name of the constant holding the value "ucp.initstring".
|
static java.lang.String |
CFG_INTPREFIX
CFG_INTPREFIX is the name of the constant holding the value "ucp.intprefix".
|
static java.lang.String |
CFG_LVA
CFG_LVA is the name of the constant holding the value "ucp.lva".
|
static java.lang.String |
CFG_OPID
CFG_OPID is the name of the constant holding the value "ucp.opid".
|
static java.lang.String |
CFG_PARITY
CFG_PARITY is the name of the constant holding the value "ucp.port.parity".
|
static java.lang.String |
CFG_PASSWORD
CFG_PASSWORD is the name of the constant holding the value "ucp.password".
|
static java.lang.String |
CFG_PORT
CFG_PORT is the name of the constant holding the value "ucp.port.name".
|
static java.lang.String |
CFG_SENDER
CFG_SENDER is the name of the constant holding the value "ucp.sender".
|
static java.lang.String |
CFG_SHORTID
CFG_SHORTID is the name of the constant holding the value "ucp.shortid".
|
static java.lang.String |
CFG_SMSC
CFG_SMSC is the name of the constant holding the value "ucp.smsc.number".
|
static java.lang.String |
CFG_STOPBITS
CFG_STOPBITS is the name of the constant holding the value "ucp.port.stopbits".
|
static java.lang.String |
CFG_SUBMIT_OPERATION
CFG_SUBMIT_SHORT_MESSAGE_OPERATION is the name of the constant holding the value "ucp.submit.operation".
|
static java.lang.String |
CFG_TCP_LOCALADDR
CFG_TCP_LOCALADDR is the name of the constant holding the value "ucp.tcp.localaddr".
|
static java.lang.String |
CFG_TCP_LOCALPORT
CFG_TCP_LOCALPORT is the name of the constant holding the value "ucp.tcp.localport".
|
static java.lang.String |
CFG_TCP_RCV_HOST
CFG_TCP_RCV_HOST is the name of the constant holding the value "ucp.tcp.receive.host".
|
static java.lang.String |
CFG_TCP_RCV_PORT
CFG_TCP_RCV_PORT is the name of the constant holding the value "ucp.tcp.receive.port".
|
static java.lang.String |
CFG_TCP_SEND_HOST
CFG_TCP_SEND_HOST is the name of the constant holding the value "ucp.tcp.send.host".
|
static java.lang.String |
CFG_TCP_SEND_PORT
CFG_TCP_SEND_PORT is the name of the constant holding the value "ucp.tcp.send.port".
|
static java.lang.String |
CFG_WINDOW_SIZE
CFG_WINDOW_SIZE is the name of the constant holding the value "ucp.window.size".
|
static java.lang.String |
CFG_XSER_NODCS
CFG_XSER_NODCS is the name of the constant holding the value "ucp.xser.nodcs".
|
static java.lang.String |
CONNECTOR_SERIAL
CONNECTOR_SERIAL is the name of the constant holding the value "SERIAL".
|
static java.lang.String |
CONNECTOR_TCP
CONNECTOR_TCP is the name of the constant holding the value "TCP".
|
Constructor and Description |
---|
UcpSmsService() |
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 |
cancelMessage(Message message)
Cancels (deletes) the buffered message with corresponding recipient address, sender address
and message ID.
|
void |
cancelMessages(Message[] messages)
Cancels (deletes) the buffered messages with corresponding recipient address, sender address
and message ID.
|
void |
connect()
Connects the UCP SMS Service to the SMSC
|
void |
delete(Message msg) |
void |
destroy()
Destroys the UCP SMS Service
|
void |
disableManualAck()
Disable manual acknowledgement.
|
void |
disconnect()
Disconnects the UCP SMS Service from the SMSC
|
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 capability)
Determine if a SMS Service has a specific capability.
|
void |
init(java.util.Properties props)
Initialize the UCP service.
|
void |
inquiryMessage(Message message)
Inquiry about the state of a buffered Message.
|
boolean |
isManualAckEnabled()
Check if manual acknowledgement is enabled/disabled.
|
void |
modifyMessage(Message message)
Deprecated.
since jSMS 2.1.8, use
replace(Message, Message) instead. |
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 using a UCP gateway.
|
void |
setWindowSize(int windowSize)
Set the window size for this service.
|
void |
startReceiving()
Start receiving Messages.
|
void |
stopReceiving()
Stop 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, supportDeleteMessage
public static final java.lang.String CFG_SMSC
public static final java.lang.String CFG_PORT
public static final java.lang.String CFG_BPS
public static final java.lang.String CFG_DATABITS
public static final java.lang.String CFG_PARITY
public static final java.lang.String CFG_STOPBITS
public static final java.lang.String CFG_FLOWCTRL
public static final java.lang.String CFG_SENDER
public static final java.lang.String CFG_INTPREFIX
public static final java.lang.String CFG_CONNECTOR
public static final java.lang.String CFG_CONNECTOR_TIMEOUT
public static final java.lang.String CONNECTOR_TCP
public static final java.lang.String CONNECTOR_SERIAL
public static final java.lang.String CFG_TCP_SEND_HOST
public static final java.lang.String CFG_TCP_SEND_PORT
public static final java.lang.String CFG_TCP_RCV_HOST
public static final java.lang.String CFG_TCP_RCV_PORT
public static final java.lang.String CFG_PASSWORD
public static final java.lang.String CFG_SHORTID
public static final java.lang.String CFG_OPID
public static final java.lang.String CFG_TCP_LOCALADDR
public static final java.lang.String CFG_TCP_LOCALPORT
public static final java.lang.String CFG_LVA
public static final java.lang.String CFG_WINDOW_SIZE
public static final java.lang.String CFG_SUBMIT_OPERATION
public static final java.lang.String CFG_INITSTRING
public static final java.lang.String CFG_XSER_NODCS
public void sendMessage(Message message) throws MessageException
connect()
has been invoked before calling this method.sendMessage
in interface SmsService
message
- the message to send.MessageException
- if the message could not be sent.UcpMessage
public void cancelMessage(Message message) throws MessageException
StatusReportMessage
should be received.message
- the message to cancelMessageException
- on failurepublic void cancelMessages(Message[] messages) throws MessageException
StatusReportMessage
should be received.messages
- to cancelMessageException
- on failurepublic void inquiryMessage(Message message) throws MessageException
StatusReportMessage
should be received.message
- to inquiryMessageException
- on failurepublic void modifyMessage(Message message) throws MessageException
replace(Message, Message)
instead.message
- to modifyMessageException
- on failurepublic int getNumberOfPendingMessages()
WindowingService
getNumberOfPendingMessages
in interface WindowingService
public int getWindowSize()
WindowingService
getWindowSize
in interface WindowingService
public void setWindowSize(int windowSize)
WindowingService
setWindowSize
in interface WindowingService
windowSize
- the window sizepublic void init(java.util.Properties props) throws MessageException
key | Allowed values |
---|---|
ucp.connector | Type of SMSC connection ("SERIAL","TCP") |
ucp.connector.timeout | Timeout (in millis) for a request to the SMSC. (2000, 5000) |
ucp.sender | Default sender address (GSM phone number) |
ucp.intprefix | Prefix for international numbers. Defaults to 00. If a recipient number contains a leading '+' character (e.g. "+41..."), the '+' character will be replaced by the international number prefix (e.g. "+41..." becomes "0041..."). |
ucp.submit.operation | UCP operation for submitting a message - 51: UCP51 (default) - 30: UCP30, when UCP51 is not supported by SMSC - 01: UCP01, when UCP30 is not supported by SMSC |
ucp.license.user | License key user name |
ucp.license.company | License key company name |
ucp.license.version | jSMS version |
ucp.license.sig | The license key itself |
ucp.smsc.number | Phone number of the UCP gateway |
ucp.port.name | Name of the serial port to use (e.g. "COM1") |
ucp.port.bps | Port speed (e.g. 9600, 19200) |
ucp.port.databits | Number of data bits ("7" or "8") |
ucp.port.parity | Parity ("ODD","EVEN","NONE") |
ucp.port.stopbits | Number of stop bits ("1","2","1.5") |
ucp.port.ucp.port.flowcontrol | Flow control ("RTSCTS", "XONXOFF","NONE") |
ucp.initstring | Init String for serial connections. Defaults to "ATZ\nATE0Q0V1\n" |
ucp.tcp.localaddr | Local address (interface) to bind. Example: "192.168.1.1" |
ucp.tcp.localport | Local port to bind |
ucp.tcp.send.host | IP address of the SMSC for sending messages |
ucp.tcp.send.port | IP port number of the SMSC for sending messages |
ucp.tcp.receive.host | IP address of the SMSC for receiving messages.
ONLY when it is different from the sending host. |
ucp.tcp.receive.port | IP port number of the SMSC for receiving messages |
ucp.shortid | Login (Short ID) |
ucp.password | Password |
ucp.lva | Large Volume Account available ("true", "false") |
ucp.window.size | Windowing size to use. (Defaults to 1 (Windowing disabled)) |
ucp.xser.nodcs | If "true", jSMS will not encode the Data Coding Scheme (DCS) as a XSer field for outgoing short messages (Defaults to false |
init
in interface SmsService
MessageException
SmsService.init()
,
SmsService.init(java.io.File)
public void destroy()
destroy
in interface SmsService
public void connect() throws MessageException
connect
in interface SmsService
MessageException
MessageEvent
,
MessageEventListener
public void disconnect() throws MessageException
disconnect
in interface SmsService
MessageException
MessageEvent
,
MessageEventListener
public void startReceiving() throws java.lang.IllegalStateException, java.io.IOException
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.lang.IllegalStateException
- if the service isn't initialized and in connected
state or there are no registered Message Event Listeners.java.io.IOException
- if the communication with the SMS gateway/device failsSmsService.addMessageEventListener(MessageEventListener)
public void stopReceiving()
SmsService
MessageEvent.RECEIVING_STOPPED
to all registered MessageEvent listeners.stopReceiving
in interface SmsService
public boolean supportReadMessage()
hasCapability(Capability.RECEIVE)
instead.supportReadMessage
in interface SmsService
public final java.lang.String getServiceName()
SmsService
getServiceName
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
- a Boolean 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.Booleanjava.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 enableManualAck()
ManualAck
ManualAck.acknowledge(Message)
.enableManualAck
in interface ManualAck
public void disableManualAck()
ManualAck
disableManualAck
in interface ManualAck
public boolean isManualAckEnabled()
ManualAck
isManualAckEnabled
in interface ManualAck
public boolean hasCapability(Capability capability)
Capability.SEND
Capability.RECEIVE
- only for UCP large accountsCapability.CANCEL
- only for UCP-SMSCs that support operation 56,
what should be the case when submitting operation is 51 (see init(Properties)
with ucp.submit.operation = 51)
Capability.QUERY
- only for UCP-SMSCs that support operation 55,
what should be the case when submitting operation is 51 (see init(Properties)
with ucp.submit.operation = 51)
hasCapability
in interface SmsService
capability
- one of the Constants in the Capability
class.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 delete(Message msg) throws java.lang.UnsupportedOperationException, java.lang.IllegalStateException, java.lang.IllegalArgumentException, MessageException
java.lang.UnsupportedOperationException
java.lang.IllegalStateException
java.lang.IllegalArgumentException
MessageException
public void query(Message msg) throws java.lang.UnsupportedOperationException, java.lang.IllegalStateException, java.lang.IllegalArgumentException, 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.java.lang.IllegalArgumentException
- if the message is null or doesn't contain
the information required for querying the message status (e.g. missing
message ID).MessageException
- if querying the status failed.public void replace(Message oldMessage, Message newMessage) throws java.lang.UnsupportedOperationException, java.lang.IllegalStateException, java.lang.IllegalArgumentException, MessageException
SmsService
replace
in interface SmsService
oldMessage
- the previously sent message to replace.newMessage
- the replacement 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.java.lang.IllegalArgumentException
- if the message is null or doesn't contain
the information required for replacing the message (e.g. missing
message ID).MessageException
- if replacement failed.object XP, Inc. © 2000-2013. All rights reserved object XP