org.openarchitectureware.debug.communication
Class PacketReceiver

java.lang.Object
  extended by org.openarchitectureware.debug.communication.PacketReceiver
All Implemented Interfaces:
java.lang.Runnable

public class PacketReceiver
extends java.lang.Object
implements java.lang.Runnable

This Runnable listens for incoming packets asynchroniously and keeps them, until they are required by customers.

Author:
Clemens Kadura (zAJKa)

Method Summary
 AbstractPacket getPacket(java.lang.Class<? extends AbstractPacket> type, int refId, long timeToWait)
          Get a packet of the requested type with a specific id, wait the specified time until it arrives, if time is negative, wait until socket will be closed
 AbstractPacket getPacket(java.lang.Class<? extends AbstractPacket> type, long timeToWait)
          Get a packet of the requested type, wait the specified time until it arrives, if time is negative, wait until socket will be closed
static PacketReceiver newPacketReceiver(Connection connection)
          create a new instance and starts the runnable in a new thread
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newPacketReceiver

public static PacketReceiver newPacketReceiver(Connection connection)
create a new instance and starts the runnable in a new thread

Parameters:
connection - the Connection that controls this data receiver.
Returns:
the instance

getPacket

public AbstractPacket getPacket(java.lang.Class<? extends AbstractPacket> type,
                                long timeToWait)
                         throws java.io.InterruptedIOException
Get a packet of the requested type, wait the specified time until it arrives, if time is negative, wait until socket will be closed

Parameters:
type - the packet type
timeToWait - until timeout
Returns:
the received packet
Throws:
java.io.InterruptedIOException

getPacket

public AbstractPacket getPacket(java.lang.Class<? extends AbstractPacket> type,
                                int refId,
                                long timeToWait)
                         throws java.io.InterruptedIOException
Get a packet of the requested type with a specific id, wait the specified time until it arrives, if time is negative, wait until socket will be closed

Parameters:
type - the packet type
refId - the id the receiving packet must have
timeToWait - until timeout
Returns:
the received packet
Throws:
java.io.InterruptedIOException
java.io.InterruptedIOException

run

public void run()
Specified by:
run in interface java.lang.Runnable