|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jabber.jabberbeans.util.SyncPacketListener
This is an interface that extends a PacketListener, so that it will filter out messages that are not the response being looked for. This is an adapter.
The main use for this class is to 'wait' on the main thread until the response for an IQ packet comes back.
Field Summary | |
private ConnectionBean |
connectionbean
Parent ConnectionBean |
private java.lang.Class |
waitClass
internal placeholder value for a Class type representing a packet type to watch out for. |
private static char |
WAITFORID
|
private static char |
WAITFORPACKETTYPE
|
private Packet |
waitPacket
internal packet value, used for reporting a Packet type to watch for, or as a placeholder for returning a packet after a incoming match is found. |
private boolean |
waitSuccessful
boolean set to indicate to the main thread that the condition was met (as opposed to just timing out |
private int |
waitType
type indicator for a single listener to be able to listen to and respond to different methods of use. |
private static char |
WAITUNKNOWN
|
Constructor Summary | |
SyncPacketListener(ConnectionBean cbean)
Creates a new IQPacketListener instance. |
Method Summary | |
void |
receivedPacket(PacketEvent p)
Monitor receivedPacket listener method. |
void |
reset()
reset restores the object to a known state, it should always be called if the object is reused. |
Packet |
sendAndWait(ContentPacket p)
sends a packet, then waits for a response, blocking indefinately until the response comes over the wire, or there is an exception |
Packet |
sendAndWait(ContentPacket p,
int timeout)
sends a packet, then waits for a response, blocking until the response comes over the wire, there is a timeout, or there is an exception |
void |
sendFailed(PacketEvent pe)
called if a packet is not successfully sent (for instance, if the connection dies while the packet is queued, or a packet is sent while disconnected). |
void |
sentPacket(PacketEvent p)
Monitor sentPacket listener method |
Packet |
waitForType(java.lang.Class c)
wait indefinately for a packet of type Class 'c' to come in. |
Packet |
waitForType(java.lang.Class c,
int timeout)
wait for a specified period of time for a packet of the same type as Class 'c' to come in |
Packet |
waitForType(Packet p)
wait indefinately for another packet of the same type to come in. |
Packet |
waitForType(Packet p,
int timeout)
wait for a specified period of time for a packet of the same type as Packet p to come in |
Methods inherited from class java.lang.Object |
|
Field Detail |
private ConnectionBean connectionbean
private Packet waitPacket
private java.lang.Class waitClass
private int waitType
private static final char WAITUNKNOWN
private static final char WAITFORID
private static final char WAITFORPACKETTYPE
private boolean waitSuccessful
Constructor Detail |
public SyncPacketListener(ConnectionBean cbean)
IQPacketListener
instance.cbean
- parent ConnectionBean
Method Detail |
public void reset()
public Packet sendAndWait(ContentPacket p) throws java.lang.InterruptedException
p
- a ContentPacket which is sent. The identifier field is used
for matching the response, so a ContentPacket is required.Packet
if successfulpublic Packet sendAndWait(ContentPacket p, int timeout) throws java.lang.InterruptedException
p
- a ContentPacket which is sent. The identifier field is used
for matching the response, so a ContentPacket is required.Packet
if successful, otherwise nullpublic Packet waitForType(Packet p) throws java.lang.InterruptedException
p
- packet which incoming packets will be comparedPacket
if successfulpublic Packet waitForType(java.lang.Class c) throws java.lang.InterruptedException
c
- class which incoming packets will be compared.Packet
if successfulpublic Packet waitForType(Packet p, int timeout) throws java.lang.InterruptedException
p
- packet which incoming packets will be compared.timeout
- maximum time to waitPacket
if successful, otherwise nullpublic Packet waitForType(java.lang.Class c, int timeout) throws java.lang.InterruptedException
class
- class which incoming packets will be compared.timeout
- maximum time to waitPacket
if successful, otherwise nullpublic void sentPacket(PacketEvent p)
sentPacket
listener methodp
- corresponding PacketEvent
valuepublic void receivedPacket(PacketEvent p)
receivedPacket
listener method. Will fire when a
packet matching the sent packet's identifier is foundp
- a PacketEvent
valuepublic void sendFailed(PacketEvent pe)
pe
- PacketEvent for the failed send
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |