Saros
Distributed Collaborative Editing and Distributed Party Programming
de.fu_berlin.inf.dpp.net.PacketCollector Class Reference

Inherits PacketListener.

List of all members.

Classes

interface  CancelHook

Public Member Functions

 PacketCollector (CancelHook cancelHook, PacketFilter packetFilter)
synchronized void cancel ()
PacketFilter getPacketFilter ()
Packet nextResult (long timeout)
boolean hasReceived ()
void processPacket (Packet packet)

Static Public Attributes

static final int MAX_PACKETS = 65536

Detailed Description

This packet collector is a special version of SMACKs org.jivesoftware.smack.PacketCollector and does not depend on a org.jivesoftware.smack.Connection for registration.


Constructor & Destructor Documentation

de.fu_berlin.inf.dpp.net.PacketCollector.PacketCollector ( CancelHook  cancelHook,
PacketFilter  packetFilter 
)

Creates a new packet collector. If the packet filter is null, then all packets will match this collector.

Parameters:
packetFilterdetermines which packets will be returned by this collector.

Member Function Documentation

synchronized void de.fu_berlin.inf.dpp.net.PacketCollector.cancel ( )

Explicitly cancels the packet collector so that no more results are queued up. Once a packet collector has been canceled, it cannot be re-enabled. Instead, a new packet collector must be created.

PacketFilter de.fu_berlin.inf.dpp.net.PacketCollector.getPacketFilter ( )

Returns the packet filter associated with this packet collector. The packet filter is used to determine what packets are queued as results.

Returns:
the packet filter.
boolean de.fu_berlin.inf.dpp.net.PacketCollector.hasReceived ( )

Returns whether this collector has already received a packet.

Packet de.fu_berlin.inf.dpp.net.PacketCollector.nextResult ( long  timeout)

Returns the next available packet. The method call will block (not return) until a packet is available or the timeout has elapsed. If the timeout elapses without a result (or the thread is interrupted), null will be returned.

Parameters:
timeoutthe amount of time in milliseconds to wait for the next packet.
Exceptions:
IllegalStateExceptionif this collector is canceled
Returns:
the next available packet.
void de.fu_berlin.inf.dpp.net.PacketCollector.processPacket ( Packet  packet)

Processes a packet to see if it meets the criteria for this packet collector. If so, the packet is added to the result queue.

If the result queue's capacity MAX_PACKETS is reached, the collector is canceled using the proved CancelHook.

Parameters:
packetthe packet to process should only be accessed by the single threaded executer of de.fu_berlin.inf.dpp.net.DispatchThreadContext

Member Data Documentation

Max number of packets that any one collector can hold. After the max is reached this collector is canceled.

 All Classes Namespaces Files Functions Variables Enumerations