info.jedi.net
Class OutputPacket

java.lang.Object
  |
  +--info.jedi.net.OutputPacket

public class OutputPacket
extends java.lang.Object
implements Packet

Class OutputPacket represents a packet being sent. It keeps track of the socket the packet will be sent from, the byte array that the packet data is stored in, and a DataOutputStream to write that data. It contains methods to send a packet and to resend it if it didn't arrive at the destination. Needs to be updated for handlers that require special callbacks

See Also:
MailDaemon

Field Summary
 java.io.DataOutputStream _stream
          Use this stream to write data to this OutputPacket
 
Constructor Summary
OutputPacket(java.net.InetAddress address, int port, HandlerStack stack)
          Creates a packet to be sent on the default socket of this MailDaemon.
OutputPacket(java.net.InetAddress address, int port, HandlerStack stack, int timeout)
          Creates a packet to be sent on the default socket of this MailDaemon.
 
Method Summary
 java.net.InetAddress address()
          The internet address this packet came from or is going to
 java.net.DatagramPacket getPacket()
          Creates a DatagramPacket with all the information in this OutputPacket.
 int id()
          The id of this packet.
 int port()
          The port this packet came from or is going to
 void send()
          Orders the handler stack to finish up creating this packet and send it off with the appropriate handler.
 HandlerStack stack()
          The protocol stack for sending this packet
 java.io.DataOutputStream stream()
          The stream for writing data to this OutputPacket
 long time()
          The sending timestamp of this packet.
 int timeout()
          Returns the timeout of this packet, in ms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_stream

public java.io.DataOutputStream _stream
Use this stream to write data to this OutputPacket
Constructor Detail

OutputPacket

public OutputPacket(java.net.InetAddress address,
                    int port,
                    HandlerStack stack,
                    int timeout)
             throws java.io.IOException
Creates a packet to be sent on the default socket of this MailDaemon. It sets up the byte array and DataOutputStream so that data can be written

OutputPacket

public OutputPacket(java.net.InetAddress address,
                    int port,
                    HandlerStack stack)
             throws java.io.IOException
Creates a packet to be sent on the default socket of this MailDaemon. It sets up the byte array and DataOutputStream so that data can be written. This constructor assumes the default timeout value.
Method Detail

address

public java.net.InetAddress address()
The internet address this packet came from or is going to
Specified by:
address in interface Packet

port

public int port()
The port this packet came from or is going to
Specified by:
port in interface Packet

id

public int id()
The id of this packet. If no ID yet exists, it will be created by this method (along with a timestamp)
Specified by:
id in interface Packet

time

public long time()
The sending timestamp of this packet. This method stamps this packet and gives it an id if it has not yet been stamped
Specified by:
time in interface Packet

timeout

public int timeout()
Returns the timeout of this packet, in ms
Specified by:
timeout in interface Packet

getPacket

public java.net.DatagramPacket getPacket()
Creates a DatagramPacket with all the information in this OutputPacket. It stores the created packet so it can be resent later. No modifications to this OutputPacket will have any effect once this is called, because the packet to be sent will already have been created.

send

public void send()
          throws java.io.IOException
Orders the handler stack to finish up creating this packet and send it off with the appropriate handler.

stream

public java.io.DataOutputStream stream()
The stream for writing data to this OutputPacket

stack

public HandlerStack stack()
The protocol stack for sending this packet