|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mobicents.protocols.smpp.util.SyncWrapper
public class SyncWrapper
Connection observer which mimics synchronous communications. This observer provides methods which block the caller until the desired response packet is available to be returned.
| Constructor Summary | |
|---|---|
SyncWrapper(Session connection)
|
|
| Method Summary | |
|---|---|
BindResp |
bind(Bind bindRequest)
Bind to the SMSC. |
BindResp |
bind(SessionType type,
String systemID,
String password,
String systemType)
Bind to the SMSC. |
BindResp |
bind(SessionType type,
String systemID,
String password,
String systemType,
int typeOfNumber,
int numberPlanIndicator,
String addressRange)
Bind to the SMSC. |
long |
getPacketTimeout()
Get the current packet timeout setting. |
void |
interruptAllBlocked()
Notify any threads that are currently blocked waiting on a response packet to give up waiting on the response and return. |
boolean |
isPacketAvailable()
Check if there are any packets available to be read. |
void |
packetReceived(Session source,
SMPPPacket packet)
Called when a new SMPP packet has been received from the SMSC. |
SMPPPacket |
readNextPacket(boolean block)
Read the next packet from the connection. |
SMPPPacket |
sendPacket(SMPPPacket packet)
Send a packet to the SMSC and wait for its response. |
void |
setPacketTimeout(long packetTimeout)
Set the timeout, in milliseconds, to block waiting for a packet. |
UnbindResp |
unbind()
Unbind from the SMSC and wait for the unbind response packet. |
void |
update(Session source,
SMPPEvent event)
Called for all events other than packet reception. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SyncWrapper(Session connection)
| Method Detail |
|---|
public BindResp bind(SessionType type,
String systemID,
String password,
String systemType)
throws IOException
type - The type of connection to bind as (transmitter, receiver
or transceiver).systemID - The system ID of this connection.password - The password of this connection.systemType - The system Type for this connection.
IOException - If an error occurs when trying to send the
bind request packet to the SMSC.
ReadTimeoutException - If the bind timeout
expires before the response is received from the SMSC.
public BindResp bind(SessionType type,
String systemID,
String password,
String systemType,
int typeOfNumber,
int numberPlanIndicator,
String addressRange)
throws IOException
type - The type of connection to bind as (transmitter, receiver
or transceiver).systemID - The system ID of this connection.password - The password of this connection.systemType - The system Type for this connection.typeOfNumber - TON to bind as.numberPlanIndicator - NPI to bind as.addressRange - Address range to bind as.
IOException - If an error occurs when trying to send the
bind request packet to the SMSC.
ReadTimeoutException - If the bind timeout
expires before the response is received from the SMSC.
public BindResp bind(Bind bindRequest)
throws IOException
bindRequest - The bind request packet to send.
IOException - If an error occurs when trying to send the bind
packet to the SMSC.
ReadTimeoutException - If the bind timeout
expires before the response is received from the SMSC.
public UnbindResp unbind()
throws IOException
IOException - If an error occurs when trying to send the unbind
packet to the SMSC.
ReadTimeoutException - If the packetTimeout
expires before the response is received from the SMSC.
public SMPPPacket sendPacket(SMPPPacket packet)
throws IOException
packet - The request packet to send to the SMSC.
null if the call timed out waiting on the packet, or if
the thread was instructed to give up the wait.
IOException - If there was a problem writing to, or reading
from, the connection.
ReadTimeoutException - If the packetTimeout
expires before the response is received from the SMSC.
public void packetReceived(Session source,
SMPPPacket packet)
SessionObserverSMPPPacket.getCommandId().
packetReceived in interface SessionObserversource - the Connection which received the packet.packet - the SMPP packet received.
public void update(Session source,
SMPPEvent event)
SessionObserverSessionObserver.packetReceived(org.mobicents.protocols.smpp.Session, org.mobicents.protocols.smpp.message.SMPPPacket)method is called in
that case. The update method is mostly used for control
events, such as signifying the exit of the receiver thread or notifying
of error conditions.
update in interface SessionObserversource - the Connection which received the packet.event - the SMPP event type.com.adenki.smpp.event.SMPPEvent#getTypepublic boolean isPacketAvailable()
true if readNextPacket(boolean) will return a
packet without blocking, false if it would block waiting
on a packet.
public SMPPPacket readNextPacket(boolean block)
throws IOException
block - true to block waiting on the next packet
to arrive, false to return whether or not a packet was
available. Note that calling this method will not return a response
packet to the calling thread if there is already another thread blocked
waiting on that response. That is, if thread 1 called sendPacket
and is waiting on a response and then thread 2 calls this method,
when the response packet arrives, thread 1 will be given the response
and thread 2 will continue to block in this method until the next
packet arrives. However, if thread 1 stops waiting for some reason
(for example, it times out waiting for its response), then thread 2
will receive the response packet.
null if no
packet was available and the caller requested non-blocking operation.
IOException - If there was a problem communicating with the
connection.public long getPacketTimeout()
setPacketTimeout(long)public void setPacketTimeout(long packetTimeout)
0, meaning wait forever for the packet.
packetTimeout - public void interruptAllBlocked()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||