j_waste.network
Class PacketHandler

java.lang.Object
  extended byjava.lang.Thread
      extended byj_waste.network.PacketHandler
All Implemented Interfaces:
NetworkConstants, java.lang.Runnable

public class PacketHandler
extends java.lang.Thread
implements NetworkConstants

This class removes packets from a priority queue and performs the appropriate action.

Version:
0.3
Author:
Mattias Ek (matek@users.sourceforge.com), Jan Lindblom (cl0wn@users.sourceforge.net)

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
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
PacketHandler(SynchronizedPrioQueue pq, java.util.LinkedList connections, RoutingTable rt)
          Constructs a new PacketHandler.
 
Method Summary
 void addPacketEventListener(PacketEventListener listener)
          Adds a listener to the list.
 void removePacketEventListener(PacketEventListener listener)
          Removes a listener from the list.
 void run()
          Runs this PacketHandler thread.
 void setMessages(java.util.ResourceBundle m)
          Sets the ResourceBundle with messages for this PacketHandler.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PacketHandler

public PacketHandler(SynchronizedPrioQueue pq,
                     java.util.LinkedList connections,
                     RoutingTable rt)
Constructs a new PacketHandler.

Parameters:
pq - The PriorityQueue where received packets are enqueued.
Method Detail

run

public void run()
Runs this PacketHandler thread. Dequeues packets from the PriorityQueue and processes them.

Specified by:
run in interface java.lang.Runnable

addPacketEventListener

public void addPacketEventListener(PacketEventListener listener)
Adds a listener to the list.

Parameters:
listener - the listener to add.

removePacketEventListener

public void removePacketEventListener(PacketEventListener listener)
Removes a listener from the list.

Parameters:
listener - the listener to remove.

setMessages

public void setMessages(java.util.ResourceBundle m)
Sets the ResourceBundle with messages for this PacketHandler.

Parameters:
m - the ResourceBundle with messages.