Class AbstractUDPServer<T>
java.lang.Object
org.openremote.agent.protocol.io.AbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel,io.netty.bootstrap.Bootstrap,InetSocketAddress>
org.openremote.agent.protocol.udp.AbstractUDPServer<T>
- All Implemented Interfaces:
IOServer<T,io.netty.channel.socket.DatagramChannel, InetSocketAddress>
- Direct Known Subclasses:
UDPStringServer
public abstract class AbstractUDPServer<T>
extends AbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel,io.netty.bootstrap.Bootstrap,InetSocketAddress>
UDP in Netty is crap; everything goes through the single server channel as it is connectionless but there is no way
of tracking packet origin across decoders. From reading each channel is single threaded so making an assumption that
we can store packet origin for processing in
AbstractNettyIOServer.onMessageReceived(T, U, W).
For outbound messages we wrap each decoder in a DatagramPacketEncoder which unfortunately only supports
MessageToMessageEncoders.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.openremote.agent.protocol.io.IOServer
IOServer.IoServerMessageConsumer<T,U, V> -
Field Summary
FieldsFields inherited from class org.openremote.agent.protocol.io.AbstractNettyIOServer
allChannels, bootstrap, channel, channelFuture, clientConnectionStatusConsumers, clientLimit, connectionStatus, connectionStatusConsumers, executorService, INITIAL_RECONNECT_DELAY_MILLIS, LOG, MAX_RECONNECT_DELAY_MILLIS, messageConsumers, RECONNECT_BACKOFF_MULTIPLIER, reconnectDelayMilliseconds, reconnectTask, workerGroup -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddEncoder(io.netty.channel.socket.DatagramChannel channel, io.netty.channel.ChannelOutboundHandler encoder) protected io.netty.bootstrap.BootstrapCreate and configure the bootstrap to use for this instanceprotected StringgetClientDescriptor(io.netty.channel.socket.DatagramChannel client) Should return a descriptor to identify the speficied client for use in log files etc.protected StringGet a string identifier that uniquely identifies the current instance of this server.protected voidhandleMessageReceived(io.netty.channel.socket.DatagramChannel channel, T message) protected voidinitChannel(io.netty.channel.socket.DatagramChannel channel) voidsendMessage(T message) Send a message to all clientsvoidsendMessage(T message, io.netty.channel.socket.DatagramChannel client) Send a message to a clientvoidsendMessage(T message, InetSocketAddress destination) Send a message to a recipient by address; for connection based protocols then the recipient must already be connected; this is mostly useful for connectionless protocols (i.e.Methods inherited from class org.openremote.agent.protocol.io.AbstractNettyIOServer
addConnectionStatusConsumer, addConnectionStatusConsumer, addDecoder, addDecoders, addEncoders, addMessageConsumer, disconnectClient, getConnectionStatus, getConnectionStatus, initClientChannel, onClientConnected, onClientDisconnected, onConnectionStatusChanged, onDecodeException, onEncodeException, onMessageReceived, removeAllConnectionStatusConsumers, removeAllMessageConsumers, removeConnectionStatusConsumer, removeConnectionStatusConsumer, removeMessageConsumer, scheduleReconnect, sendClientConnectionStatus, start, stop
-
Field Details
-
localAddress
-
lastMessageSender
-
-
Constructor Details
-
AbstractUDPServer
-
-
Method Details
-
getSocketAddressString
Description copied from class:AbstractNettyIOServerGet a string identifier that uniquely identifies the current instance of this server. e.g. tcp://IP:PORT- Specified by:
getSocketAddressStringin classAbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel, io.netty.bootstrap.Bootstrap, InetSocketAddress>
-
getClientDescriptor
Description copied from class:AbstractNettyIOServerShould return a descriptor to identify the speficied client for use in log files etc.- Specified by:
getClientDescriptorin classAbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel, io.netty.bootstrap.Bootstrap, InetSocketAddress>
-
createAndConfigureBootstrap
protected io.netty.bootstrap.Bootstrap createAndConfigureBootstrap()Description copied from class:AbstractNettyIOServerCreate and configure the bootstrap to use for this instance- Specified by:
createAndConfigureBootstrapin classAbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel, io.netty.bootstrap.Bootstrap, InetSocketAddress>
-
initChannel
protected void initChannel(io.netty.channel.socket.DatagramChannel channel) - Overrides:
initChannelin classAbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel, io.netty.bootstrap.Bootstrap, InetSocketAddress>
-
sendMessage
Description copied from interface:IOServerSend a message to all clients- Specified by:
sendMessagein interfaceIOServer<T,io.netty.channel.socket.DatagramChannel, InetSocketAddress> - Overrides:
sendMessagein classAbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel, io.netty.bootstrap.Bootstrap, InetSocketAddress>
-
sendMessage
Description copied from interface:IOServerSend a message to a client- Specified by:
sendMessagein interfaceIOServer<T,io.netty.channel.socket.DatagramChannel, InetSocketAddress> - Overrides:
sendMessagein classAbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel, io.netty.bootstrap.Bootstrap, InetSocketAddress>
-
sendMessage
Description copied from class:AbstractNettyIOServerSend a message to a recipient by address; for connection based protocols then the recipient must already be connected; this is mostly useful for connectionless protocols (i.e. UDP where only a single channel exists)- Overrides:
sendMessagein classAbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel, io.netty.bootstrap.Bootstrap, InetSocketAddress>
-
addEncoder
protected void addEncoder(io.netty.channel.socket.DatagramChannel channel, io.netty.channel.ChannelOutboundHandler encoder) - Overrides:
addEncoderin classAbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel, io.netty.bootstrap.Bootstrap, InetSocketAddress>
-
handleMessageReceived
- Overrides:
handleMessageReceivedin classAbstractNettyIOServer<T,io.netty.channel.socket.DatagramChannel, io.netty.bootstrap.Bootstrap, InetSocketAddress>
-