public class FloodConnector extends java.lang.Object implements IPacketConnector, IListener
EVENT_PACKET_CLOSED, EVENT_PACKET_RECEIVED| Constructor and Description |
|---|
FloodConnector(IOperator operator,
IPacketConnector connector)
Creates a new flood connector that uses the specified connector
as underlying implementation.
|
FloodConnector(IOperator operator,
IPacketConnector connector,
short scope)
Creates a flood connector that uses the specified connector as
underlying implementation.
|
FloodConnector(IOperator operator,
IPacketConnector connector,
short scope,
int limit)
Creates a flood connector that uses the specified connector as
underlying implementation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPacketListener(int type,
IListener listener)
Adds a packet listener for the specified set of events.
|
IPacket |
createPacket()
Creates a packet that can be used to send and receive data.
|
int |
getPacketLength()
Returns the maximum packet length.
|
IPlugin |
getPlugin()
Returns the plug-in that is associated with the underlying
connector.
|
void |
handleEvent(Event event)
Called whenever the underlying connector creates an event.
|
void |
release()
Releases this connector as well as the underlying connector.
|
boolean |
removePacketListener(int type,
IListener listener)
Removes a packet listener for the specified events.
|
void |
sendPacket(IPacket packet)
Sends the specified packet if possible.
|
public FloodConnector(IOperator operator, IPacketConnector connector)
operator - The operator to schedule new transmissions.connector - The underlying connector used to transmit and
receive packets.java.lang.NullPointerException - Thrown if the connector is null.public FloodConnector(IOperator operator, IPacketConnector connector, short scope)
operator - The operator to schedule new transmissions.connector - The connector used to receive and transmit packets.scope - The flooding scope (i.e., the maximum hop count).java.lang.NullPointerException - Thrown if the connector is null.java.lang.IllegalArgumentException - Thrown if the scope is not a
positive value (excluding 0).public FloodConnector(IOperator operator, IPacketConnector connector, short scope, int limit)
operator - The operator to schedule new transmissions.connector - The connector used to receive and transmit packets.scope - The flooding scope (i.e., the maximum hop count).limit - The maximum buffer size for packet ids.java.lang.NullPointerException - Thrown if the connector is null.java.lang.IllegalArgumentException - Thrown if the scope or the buffer
limit are not positive values (excluding 0).public void addPacketListener(int type,
IListener listener)
addPacketListener in interface IPacketConnectortype - The type of events.listener - The listener to add.public boolean removePacketListener(int type,
IListener listener)
removePacketListener in interface IPacketConnectortype - The type of events to unregister.listener - The listener to remove.public IPacket createPacket() throws java.io.IOException
createPacket in interface IPacketConnectorjava.io.IOException - Thrown if the packet cannot be created.public IPlugin getPlugin()
getPlugin in interface IConnectorpublic void handleEvent(Event event)
handleEvent in interface IListenerevent - The event received from the underlying connector.public void release()
release in interface IConnectorpublic void sendPacket(IPacket packet) throws java.io.IOException
sendPacket in interface IPacketConnectorpacket - The packet that should be transfered.java.io.IOException - Thrown by the underlying connector.public int getPacketLength()
getPacketLength in interface IPacketConnector