|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | 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.
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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 successful
java.lang.InterruptedException
public 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 null
java.lang.InterruptedException
public Packet waitForType(Packet p) throws java.lang.InterruptedException
p
- packet which incoming packets will be compared
Packet
if successful
java.lang.InterruptedException
public Packet waitForType(java.lang.Class c) throws java.lang.InterruptedException
c
- class which incoming packets will be compared.
Packet
if successful
java.lang.InterruptedException
public Packet waitForType(Packet p, int timeout) throws java.lang.InterruptedException
p
- packet which incoming packets will be compared.timeout
- maximum time to wait
Packet
if successful, otherwise null
java.lang.InterruptedException
public Packet waitForType(java.lang.Class c, int timeout) throws java.lang.InterruptedException
timeout
- maximum time to wait
Packet
if successful, otherwise null
java.lang.InterruptedException
public void sentPacket(PacketEvent p)
sentPacket
listener method
sentPacket
in interface PacketListener
p
- corresponding PacketEvent
valuepublic void receivedPacket(PacketEvent p)
receivedPacket
listener method. Will fire when a
packet matching the sent packet's identifier is found
receivedPacket
in interface PacketListener
p
- a PacketEvent
valuepublic void sendFailed(PacketEvent pe)
PacketListener
sendFailed
in interface PacketListener
pe
- PacketEvent for the failed send
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |