public class GroupConnector extends java.lang.Object implements IPacketConnector, IListener
EVENT_PACKET_CLOSED, EVENT_PACKET_RECEIVED
Constructor and Description |
---|
GroupConnector(int length,
short group)
Creates a new packet connector that transfers and
receives data.
|
GroupConnector(int length,
short group,
java.lang.Short ability)
Creates a new packet connector that transfers and
receives data.
|
Modifier and Type | Method and Description |
---|---|
void |
addConnector(IPacketConnector c)
Adds the specified packet connector to the set of
connectors used by this connector.
|
void |
addPacketListener(int type,
IListener listener)
Adds a packet listener for the specified type of events.
|
IPacket |
createPacket()
Creates a new packet that can be used to receive and
transfer data from this packet connector.
|
java.lang.Short |
getAbility()
Returns the ability or null.
|
short |
getGroup()
Returns the group of the packet connector.
|
int |
getPacketLength()
Returns the maximum packet length.
|
IPlugin |
getPlugin()
Returns the plug-in that created the connector.
|
void |
handleEvent(Event event)
Called by the underlying connectors to signal an incoming
packet or a closed connector.
|
void |
release()
Releases the specified packet connector and removes all references.
|
void |
removeConnector(IPacketConnector c)
Adds the specified packet connector to the set of
connectors used by this connector.
|
boolean |
removePacketListener(int type,
IListener listener)
Removes a listener for the specified type of events.
|
void |
sendPacket(IPacket packet)
Transfers a packet through this packet connector.
|
public GroupConnector(int length, short group)
group
- The group of the connector.length
- The maximum packet length that shall be
supported. If a connector does not support this length,
this connector will start fragmenting the connector.public GroupConnector(int length, short group, java.lang.Short ability)
group
- The group of the connector.ability
- The ability of the connector.length
- The maximum packet length that shall be
supported. If a connector does not support this length,
this connector will start fragmenting the connector.public int getPacketLength()
getPacketLength
in interface IPacketConnector
public void addPacketListener(int type, IListener listener)
addPacketListener
in interface IPacketConnector
type
- The event types.listener
- The listener to register.public boolean removePacketListener(int type, IListener listener)
removePacketListener
in interface IPacketConnector
type
- The type of events.listener
- The listener to remove.public void handleEvent(Event event)
handleEvent
in interface IListener
event
- The event created by one of the underlying connectors.public void addConnector(IPacketConnector c)
c
- The packet connector to add.public void removeConnector(IPacketConnector c)
c
- The packet connector to add.public IPacket createPacket() throws java.io.IOException
createPacket
in interface IPacketConnector
java.io.IOException
- Thrown if the connector is closed already.public void sendPacket(IPacket packet) throws java.io.IOException
sendPacket
in interface IPacketConnector
packet
- The packet that should be transfered.java.io.IOException
- Thrown if the packet connector has been
closed already.public void release()
release
in interface IConnector
public short getGroup()
public java.lang.Short getAbility()
public IPlugin getPlugin()
getPlugin
in interface IConnector