|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface SmsService
This interface defines the methods to send and receive GSM Short Messages (SMS).
| Field Summary | |
|---|---|
static java.lang.String |
VERSION
Constant containing the module version. |
| Method Summary | |
|---|---|
void |
addMessageEventListener(MessageEventListener listener)
Register a Message Event listener with this Service. |
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 |
disconnect()
Disconnect from the GSM device or SMS gateway. |
int |
getKeepAliveInterval()
Get the currently set keepalive interval. |
long |
getLastIsAliveTime()
Returns the time of the last successful isAlive() invocation. |
java.util.Properties |
getProperties()
Get the properties passed to the service. |
java.lang.String |
getServiceName()
Returns the name of the service. |
boolean |
hasCapability(Capability capability)
Determine if a SMS Service has a specific capability. |
void |
init()
Initialize this service. |
void |
init(java.io.File file)
Initialize this Service with properties defined in the given file. |
void |
init(java.util.Properties props)
Initialize this service. |
boolean |
isAlive()
Returns true if the connection to the GSM device or SMSC is alive, false otherwise. |
boolean |
isConnected()
Returns true if the Service is currently connected to the GSM device or SMS gateway, false otherwise. |
boolean |
isInitialized()
Returns true if the Service has been sucessfuly initalized, false otherwise. |
boolean |
isKeepAliveActive()
Returns true, if jSMS is keeping the connection to the GSM device or SMSC alive, false otherwise. |
boolean |
isReceiving()
Returns true if the Service is currently receiving incoming short messages, false otherwise. |
void |
query(Message msg)
Query the status of a previously submitted message. |
void |
removeMessageEventListener(MessageEventListener listener)
Remove a Listener from the List of Message Event listeners. |
void |
replace(Message oldMessage,
Message newMessage)
Replace a previously submitted message. |
void |
sendMessage(Message message)
Send a message to a GSM recipient. |
void |
setKeepAliveInterval(int interval)
Set the keep-alive interval of this Service. |
void |
startReceiving()
Start receiving Messages. |
void |
stopReceiving()
Stop receiving Messages. |
boolean |
supportDeleteMessage()
Deprecated. since jSMS 2.1.8. |
boolean |
supportReadMessage()
Deprecated. since jSMS 2.1.8, use hasCapability(Capability.RECEIVE)
instead. |
| Field Detail |
|---|
static final java.lang.String VERSION
| Method Detail |
|---|
void addMessageEventListener(MessageEventListener listener)
listener - an Object implementing the MessageEventListener interface.MessageEvent,
MessageEventListenervoid removeMessageEventListener(MessageEventListener listener)
receiving messages, this method
will automatically stop receiving (by calling stopReceiving()).
listener - the listener to remove
void sendMessage(Message message)
throws MessageException
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.
message - the message to send.
MessageException - if the message could not be sent.boolean supportReadMessage()
hasCapability(Capability.RECEIVE)
instead.
boolean supportDeleteMessage()
void connect()
throws MessageException
MessageEvent.DEVICE_READY event to all registered
MessageEventListeners.
MessageExceptionMessageEvent,
MessageEventListener
void disconnect()
throws MessageException
MessageEvent.DEVICE_NOT_READY even to all
registered MessageEventListeners.
MessageExceptionMessageEvent,
MessageEventListenerboolean isConnected()
boolean isReceiving()
startReceiving(),
stopReceiving()boolean isInitialized()
init(),
init(Properties),
init(File)boolean isAlive()
void setKeepAliveInterval(int interval)
isAlive(). If the connection is down, the service broadcasts a
MessageEvent of type DEVICE_NOT_RESPONDING
to all registered MessageEvent listeners. The user of the SmsService may then
decide to reconnect to the SMSC by calling disconnect() followed by
connect().
interval - the keepalive interval in secondsMessageEvent,
addMessageEventListener(MessageEventListener)boolean isKeepAliveActive()
connect()ed to the
SMSC this method always returns false.
connect(),
setKeepAliveInterval(int)int getKeepAliveInterval()
sms.keepalive.interval).
At runtime, the interval can be changed by calling setKeepAliveInterval(int).
long getLastIsAliveTime()
isAlive() invocation.
void init(java.util.Properties props)
throws MessageException
MessageExceptioninit(),
init(java.io.File)
void init()
throws MessageException
MessageExceptioninit(Properties),
init(java.io.File)
void init(java.io.File file)
throws java.io.IOException,
MessageException
file - the file containing jSMS init properties
java.io.IOException - if the passed file could not be loaded
MessageException - if the Service could not be initialized properlyinit(),
init(Properties)void destroy()
void startReceiving()
throws java.io.IOException,
java.lang.IllegalStateException
MessageEventListener with the Service. After receiving
has started, the service will broadcast a MessageEvent of type
MessageEvent.RECEIVING_STARTED to all registered MessageEvent listeners.
java.io.IOException - if the communication with the SMS gateway/device fails
java.lang.IllegalStateException - if the service isn't initialized and in connected
state or there are no registered Message Event Listeners.addMessageEventListener(MessageEventListener)void stopReceiving()
MessageEvent.RECEIVING_STOPPED
to all registered MessageEvent listeners.
java.util.Properties getProperties()
init(Properties)java.lang.String getServiceName()
boolean hasCapability(Capability capability)
capability - one of the Constants in the Capability class.
void cancel(Message msg)
throws java.lang.UnsupportedOperationException,
java.lang.IllegalStateException,
java.lang.IllegalArgumentException,
MessageException
status report,
a MessageEvent of type STATUS_RECEIVED
will be generated upon cancellation of the message.
msg - The previously sent 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 cancelling the message (e.g. missing
message ID).
MessageException - if cancellation failed.
void replace(Message oldMessage,
Message newMessage)
throws java.lang.UnsupportedOperationException,
java.lang.IllegalStateException,
java.lang.IllegalArgumentException,
MessageException
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.
void query(Message msg)
throws java.lang.UnsupportedOperationException,
java.lang.IllegalStateException,
java.lang.IllegalArgumentException,
MessageException
MessageEvent of
type STATUS_RECEIVED.
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.
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||