public class RadiusClient<T extends io.netty.channel.socket.DatagramChannel>
extends java.lang.Object
This object is thread safe, but requires a packet manager to avoid confusion with the mapping of request and result packets.
Constructor and Description |
---|
RadiusClient(io.netty.channel.EventLoopGroup eventLoopGroup,
io.netty.channel.ChannelFactory<T> factory,
ClientHandler clientHandler,
java.net.InetAddress listenAddress,
int port) |
Modifier and Type | Method and Description |
---|---|
io.netty.util.concurrent.Future<RadiusPacket> |
communicate(RadiusPacket packet,
RadiusEndpoint endpoint,
int maxAttempts) |
protected io.netty.channel.ChannelFuture |
listen(T channel,
java.net.InetSocketAddress listenAddress) |
protected io.netty.channel.socket.DatagramPacket |
makeDatagramPacket(RadiusPacket packet,
RadiusEndpoint endpoint)
Creates a datagram packet from a RadiusPacket to be send.
|
io.netty.channel.ChannelFuture |
startChannel()
Registers the channel and binds to address.
|
void |
stop()
Closes channel socket
|
public RadiusClient(io.netty.channel.EventLoopGroup eventLoopGroup, io.netty.channel.ChannelFactory<T> factory, ClientHandler clientHandler, java.net.InetAddress listenAddress, int port)
eventLoopGroup
- for both channel IO and processingfactory
- to create new ChannelclientHandler
- to log outgoing packets and handle incoming packets/responseslistenAddress
- local address to bind to, will be wildcard address if nullport
- port to bind to, or set to 0 to let system choosepublic void stop()
public io.netty.channel.ChannelFuture startChannel()
Also run implicitly if communicate(RadiusPacket, RadiusEndpoint, int)
is called.
protected io.netty.channel.ChannelFuture listen(T channel, java.net.InetSocketAddress listenAddress)
channel
- to listen onlistenAddress
- the address to bind topublic io.netty.util.concurrent.Future<RadiusPacket> communicate(RadiusPacket packet, RadiusEndpoint endpoint, int maxAttempts)
protected io.netty.channel.socket.DatagramPacket makeDatagramPacket(RadiusPacket packet, RadiusEndpoint endpoint) throws java.io.IOException, RadiusException
packet
- RadiusPacketendpoint
- destination port numberjava.io.IOException
- error when writing packet to output streamRadiusException
- error when encoding RadiusPacket attributes