public class IPPacketConnector extends java.lang.Object implements IPacketConnector, IOperation
EVENT_PACKET_CLOSED, EVENT_PACKET_RECEIVED
Constructor and Description |
---|
IPPacketConnector(IIPPlugin plugin,
java.net.DatagramSocket socket,
java.net.InetAddress group,
int length)
Creates a new packet connector that broadcasts messages
using the specified datagram socket.
|
Modifier and Type | Method and Description |
---|---|
void |
addPacketListener(int type,
IListener listener)
Adds a listener for the specified events.
|
IPacket |
createPacket()
Creates a packet that can be used to transfer and receive
data from the connector.
|
int |
getPacketLength()
Returns the packet length.
|
IPlugin |
getPlugin()
Returns the ip transceiver plug-in as parent of this plug-in.
|
void |
perform(IMonitor monitor)
Called to run the receiving thread.
|
void |
release()
Releases the socket and removes the connector from the
list of connectors.
|
boolean |
removePacketListener(int type,
IListener listener)
Removes the specified listener for the specified events.
|
void |
sendPacket(IPacket packet)
Transfers a packet using the underlying socket.
|
public IPPacketConnector(IIPPlugin plugin, java.net.DatagramSocket socket, java.net.InetAddress group, int length)
socket
- The socket used to broadcast messages.length
- The maximum packet length.plugin
- The creating plug-in.group
- The group id.public IPacket createPacket() throws java.io.IOException
createPacket
in interface IPacketConnector
java.io.IOException
- Thrown if the connector is released.public IPlugin getPlugin()
getPlugin
in interface IConnector
public void sendPacket(IPacket packet) throws java.io.IOException
sendPacket
in interface IPacketConnector
packet
- The packet to transfer.java.io.IOException
- Thrown if the operation failed.public void addPacketListener(int type, IListener listener)
addPacketListener
in interface IPacketConnector
type
- The events to listen for.listener
- The listener to add.public boolean removePacketListener(int type, IListener listener)
removePacketListener
in interface IPacketConnector
type
- The types of events.listener
- The listener to remove.public int getPacketLength()
getPacketLength
in interface IPacketConnector
public void perform(IMonitor monitor)
perform
in interface IOperation
monitor
- The monitor to abort the operation.public void release()
release
in interface IConnector