j_waste.network
Class ChatPacket

java.lang.Object
  extended byj_waste.network.Packet
      extended byj_waste.network.HeadedPacket
          extended byj_waste.network.ChatPacket
All Implemented Interfaces:
NetworkConstants

public class ChatPacket
extends HeadedPacket
implements NetworkConstants

This is the class for the Chat packet type.

Version:
0.2
Author:
Jan Lindblom (cl0wn@users.sourceforge.net)

Field Summary
 
Fields inherited from class j_waste.network.HeadedPacket
iscomplete, packetData, padBytes
 
Fields inherited from class j_waste.network.Packet
packet
 
Fields inherited from interface j_waste.network.NetworkConstants
ABORT, CAP_BANDWIDTH, CAP_REMOTE_IP, CAP_SATURATION, GENERAL_TYPE_BROADCAST, GENERAL_TYPE_LOCAL, GENERAL_TYPE_ROUTED, HEADER_SIZE, MAX_BROADCAST_SIZE, MAX_ROUTED_SIZE, NO_ABORT, PREMATURE_ABORT, PRIO_CHAT, PRIO_CHAT_REPLY, PRIO_FILE_REQ_REPLY, PRIO_FILE_REQUEST, PRIO_KEYDIST, PRIO_KEYDIST_REPLY, PRIO_LCAPS, PRIO_LOCAL_SATURATE, PRIO_PING, PRIO_SEARCH, PRIO_SEARCH_REPLY, PRIO_SEARCH_USERLIST, PRIO_UPLOAD, TYPE_CHAT, TYPE_CHAT_REPLY, TYPE_FILE_REQ_REPLY, TYPE_FILE_REQUEST, TYPE_KEYDIST, TYPE_KEYDIST_REPLY, TYPE_LCAPS, TYPE_LOCAL_SATURATE, TYPE_PING, TYPE_SEARCH, TYPE_SEARCH_REPLY, TYPE_SEARCH_USERLIST, TYPE_UPLOAD
 
Constructor Summary
ChatPacket()
          Base constructor, creates an empty ChatPacket.
ChatPacket(byte[] pkg)
          Constructs a ChatPacket given a byte array representation of the Packet.
ChatPacket(java.lang.String s, java.lang.String r, java.lang.String m)
          Constructs a ChatPacket with given sender, recipient and message.
ChatPacket(java.lang.String s, java.lang.String r, java.lang.String m, byte[] guid)
          Constructs a ChatPacket with given sender, recipient, message and GUID.
 
Method Summary
 void finalizePacket()
          Finalizes this ChatPacket.
 java.lang.String getMessage()
          Returns the message of this ChatPacket.
 java.lang.String getRecipient()
          Returns the recipient of this ChatPacket.
 java.lang.String getSender()
          Returns the sender of this ChatPacket.
 void setMessage(java.lang.String m)
          Sets the message of this ChatPacket.
 void setRecipient(java.lang.String r)
          Sets the recipient of this ChatPacket.
 void setSender(java.lang.String s)
          Sets the sender of this ChatPacket.
 byte[] toByteArray()
          Returns a byte array representation of the packet.
 
Methods inherited from class j_waste.network.HeadedPacket
createPacket, getData, getGeneralType, getGUID, getHeader, getIntPrio, getIntType, getLength, getMD5, getPrio, getTTL, getType, setLength, setTTL
 
Methods inherited from class j_waste.network.Packet
padCD, reverseBytes, reverseInt, reverseShort, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChatPacket

public ChatPacket()
Base constructor, creates an empty ChatPacket.


ChatPacket

public ChatPacket(java.lang.String s,
                  java.lang.String r,
                  java.lang.String m)
Constructs a ChatPacket with given sender, recipient and message.

Parameters:
s - the sender.
r - the recipient.
m - the message.

ChatPacket

public ChatPacket(java.lang.String s,
                  java.lang.String r,
                  java.lang.String m,
                  byte[] guid)
Constructs a ChatPacket with given sender, recipient, message and GUID.

Parameters:
s - the sender.
r - the recipient.
m - the message.
guid - the GUID.

ChatPacket

public ChatPacket(byte[] pkg)
           throws InvalidPacketException
Constructs a ChatPacket given a byte array representation of the Packet.

Parameters:
pkg - the Packet.
Method Detail

setSender

public void setSender(java.lang.String s)
Sets the sender of this ChatPacket.

Parameters:
s - the sender.

getSender

public java.lang.String getSender()
Returns the sender of this ChatPacket.

Returns:
the sender.

setRecipient

public void setRecipient(java.lang.String r)
Sets the recipient of this ChatPacket.

Parameters:
r - the recipient.

getRecipient

public java.lang.String getRecipient()
Returns the recipient of this ChatPacket.

Returns:
the recipient.

setMessage

public void setMessage(java.lang.String m)
Sets the message of this ChatPacket.

Parameters:
m - the message.

getMessage

public java.lang.String getMessage()
Returns the message of this ChatPacket.

Returns:
the message.

finalizePacket

public void finalizePacket()
Finalizes this ChatPacket.

Overrides:
finalizePacket in class HeadedPacket

toByteArray

public byte[] toByteArray()
Returns a byte array representation of the packet.

Overrides:
toByteArray in class HeadedPacket
Returns:
a byte array representation of the packet.