Class TCPProtocol
java.lang.Object
org.openremote.agent.protocol.AbstractProtocol<U,X>
org.openremote.agent.protocol.io.AbstractIOClientProtocol<T,U,V,W,X>
org.openremote.agent.protocol.io.AbstractNettyIOClientProtocol<T,U,W,X,V>
org.openremote.agent.protocol.tcp.AbstractTCPClientProtocol<TCPProtocol,TCPAgent,org.openremote.model.asset.agent.DefaultAgentLink,String,TCPIOClient<String>>
org.openremote.agent.protocol.tcp.TCPProtocol
- All Implemented Interfaces:
org.openremote.model.asset.agent.Protocol<TCPAgent>
public class TCPProtocol
extends AbstractTCPClientProtocol<TCPProtocol,TCPAgent,org.openremote.model.asset.agent.DefaultAgentLink,String,TCPIOClient<String>>
This is a generic TCP client protocol for communicating with TCP servers; it uses the
TCPIOClient
to
handle the communication and all messages are processed as strings; if you require custom message type handling or
more specific handling then sub class the AbstractTCPClientProtocol
).
To use this protocol create a TCPAgent
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
protected final List<org.openremote.model.util.Pair<org.openremote.model.attribute.AttributeRef,
Consumer<String>>> Fields inherited from class org.openremote.agent.protocol.io.AbstractIOClientProtocol
client
Fields inherited from class org.openremote.agent.protocol.AbstractProtocol
agent, assetService, datapointService, dynamicAttributes, executorService, linkedAttributes, messageBrokerContext, predictedDatapointService, processorLock, producerTemplate, scheduledExecutorService, timerService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
createWriteMessage
(org.openremote.model.asset.agent.DefaultAgentLink agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Generate the actual message to send to theIOClient
for thisAttributeEvent
protected void
doLinkAttribute
(String assetId, org.openremote.model.attribute.Attribute<?> attribute, org.openremote.model.asset.agent.DefaultAgentLink agentLink) Link anAttribute
to its linkedAgent
.protected void
doUnlinkAttribute
(String assetId, org.openremote.model.attribute.Attribute<?> attribute, org.openremote.model.asset.agent.DefaultAgentLink agentLink) Unlink anAttribute
from its linkedAgent
.protected Supplier<io.netty.channel.ChannelHandler[]>
Gets the NettyChannelHandler
s for the IO clientGet the name for this protocolprotected void
onMessageReceived
(String message) Called when theIOClient
receives a message from the serverMethods inherited from class org.openremote.agent.protocol.tcp.AbstractTCPClientProtocol
doCreateIoClient
Methods inherited from class org.openremote.agent.protocol.io.AbstractNettyIOClientProtocol
createIoClient
Methods inherited from class org.openremote.agent.protocol.io.AbstractIOClientProtocol
doLinkedAttributeWrite, doStart, doStop, getGenericStringEncodersAndDecoders, getProtocolInstanceUri, onConnectionStatusChanged
Methods inherited from class org.openremote.agent.protocol.AbstractProtocol
getAgent, getLinkedAttributes, linkAttribute, onAgentAttributeChanged, processLinkedAttributeWrite, sendAttributeEvent, sendAttributeEvent, setAssetService, setConnectionStatus, start, stop, toString, unlinkAttribute, updateLinkedAttribute, updateLinkedAttribute
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.openremote.model.asset.agent.Protocol
prefixLogMessage
-
Field Details
-
PROTOCOL_DISPLAY_NAME
- See Also:
-
protocolMessageConsumers
-
-
Constructor Details
-
TCPProtocol
-
-
Method Details
-
getProtocolName
Description copied from interface:org.openremote.model.asset.agent.Protocol
Get the name for this protocol -
doLinkAttribute
protected void doLinkAttribute(String assetId, org.openremote.model.attribute.Attribute<?> attribute, org.openremote.model.asset.agent.DefaultAgentLink agentLink) Description copied from class:AbstractProtocol
Link anAttribute
to its linkedAgent
.- Specified by:
doLinkAttribute
in classAbstractProtocol<TCPAgent,
org.openremote.model.asset.agent.DefaultAgentLink>
-
doUnlinkAttribute
protected void doUnlinkAttribute(String assetId, org.openremote.model.attribute.Attribute<?> attribute, org.openremote.model.asset.agent.DefaultAgentLink agentLink) Description copied from class:AbstractProtocol
Unlink anAttribute
from its linkedAgent
.- Specified by:
doUnlinkAttribute
in classAbstractProtocol<TCPAgent,
org.openremote.model.asset.agent.DefaultAgentLink>
-
getEncoderDecoderProvider
Description copied from class:AbstractNettyIOClientProtocol
Gets the NettyChannelHandler
s for the IO client- Specified by:
getEncoderDecoderProvider
in classAbstractNettyIOClientProtocol<TCPProtocol,
TCPAgent, String, TCPIOClient<String>, org.openremote.model.asset.agent.DefaultAgentLink>
-
onMessageReceived
Description copied from class:AbstractIOClientProtocol
Called when theIOClient
receives a message from the server- Specified by:
onMessageReceived
in classAbstractIOClientProtocol<TCPProtocol,
TCPAgent, String, TCPIOClient<String>, org.openremote.model.asset.agent.DefaultAgentLink>
-
createWriteMessage
protected String createWriteMessage(org.openremote.model.asset.agent.DefaultAgentLink agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Description copied from class:AbstractIOClientProtocol
Generate the actual message to send to theIOClient
for thisAttributeEvent
- Specified by:
createWriteMessage
in classAbstractIOClientProtocol<TCPProtocol,
TCPAgent, String, TCPIOClient<String>, org.openremote.model.asset.agent.DefaultAgentLink>
-