public final class ChannelAccessSearchUDPServerMessage extends ChannelAccessSearchMessage
CA_PROTO_SEARCH
message that is sent from a
server to a client via UDP in reply to a
ChannelAccessSearchClientMessage
. This message carries information
about how to connect to the requested channel.ChannelAccessCommand.CA_PROTO_SEARCH
command, originalMessageHeader
Constructor and Description |
---|
ChannelAccessSearchUDPServerMessage(ChannelAccessVersion version,
int cid,
Inet4Address serverAddress,
int serverPort)
Creates a
CA_PROTO_SEARCH message that can be sent from a
server to a client via UDP. |
Modifier and Type | Method and Description |
---|---|
protected static ChannelAccessSearchUDPServerMessage |
deserialize(ChannelAccessMessageHeader messageHeader,
ByteSource byteSource,
Inet4Address originatingServerAddress,
int originatingServerPort)
Constructs a message from a header and a byte source.
|
boolean |
equals(Object obj)
Tells whether the specified object represents the same message.
|
int |
getChannelCID()
Returns the channel ID that is used by the client to identify the
channel.
|
Inet4Address |
getServerAddress()
Returns the IP address of the server that is serving the requested
channel.
|
int |
getServerPort()
Returns the TCP port number on which the server that is serving the
requested channel is listening.
|
ChannelAccessVersion |
getVersion()
Returns the Channel Access version supported by this server.
|
int |
hashCode()
Returns a hash code value for this message.
|
protected void |
serialize(ByteSink byteSink,
ChannelAccessVersion version,
int maxPayloadSize,
Charset charset)
Serializes this message to a byte sink.
|
String |
toString()
Returns a string representation of this message.
|
protected void |
verify(ChannelAccessVersion version,
int maxPayloadSize,
Charset charset)
Verifies that this message can be serialized.
|
addByteArrayToStringBuilder, calculatePaddingSize, getCommand, getOriginalMessageHeader, hasOriginalMessageHeader, serializeHeader, verifyHeader
public ChannelAccessSearchUDPServerMessage(ChannelAccessVersion version, int cid, Inet4Address serverAddress, int serverPort)
CA_PROTO_SEARCH
message that can be sent from a
server to a client via UDP.version
- Channel Access protocol version supported by this server (or
the server that is serving the channel).cid
- client-side channel identifier. This is the identifier that
has been sent by the client with the search request and is
used by the client to map the response to the right channel.serverAddress
- IP address of the server serving the channel. If this is
null
or the wildcard address, the client will try
to connect to the server sending this message.serverPort
- TCP port of the server serving the channel. For messages using
a protocol version older than Channel Access version 4.5, the
port is not sent with the message and the originating port of
the UDP message is used instead.public int getChannelCID()
public Inet4Address getServerAddress()
public int getServerPort()
public ChannelAccessVersion getVersion()
public boolean equals(Object obj)
ChannelAccessMessage
Tells whether the specified object represents the same message.
Two messages are considered equal if they are of the same type and have the same headers and payload. For comparing the types, the actual Java type and not just the Channel Access command is compared.
equals
in class ChannelAccessMessage
obj
- reference object with which this object is compared.true
if obj
is a message that is of the
same type and has the same headers and payload as this message.
false
if obj
is null
or of
a different type than this message or differs in the headers or
payload.public int hashCode()
ChannelAccessMessage
Returns a hash code value for this message. This method is supported for the benefit of hash tables. The hash code is calculated as a combination of the hash codes of this messages headers (including the Channel Access command) and its payload (if present).
If two messages are equal (as indicated by the return value of
ChannelAccessMessage.equals(Object)
), they also have the same hash code. However, the
fact that two messages have the same hash code does not imply that they
are equal.
hashCode
in class ChannelAccessMessage
public String toString()
ChannelAccessMessage
toString
in class ChannelAccessMessage
protected void serialize(ByteSink byteSink, ChannelAccessVersion version, int maxPayloadSize, Charset charset)
ChannelAccessMessage
ChannelAccessMessageCodec
.serialize
in class ChannelAccessMessage
byteSink
- byte sink that is used for writing the serialized data.version
- protocol version to stay compatible with. This is the protocol
version of the peer the message is sent to.maxPayloadSize
- maximum size of the payload.charset
- encoding to use for serializing the string data (e.g. channel
names, error strings, string data-values).protected void verify(ChannelAccessVersion version, int maxPayloadSize, Charset charset)
ChannelAccessMessage
ChannelAccessMessageCodec
.verify
in class ChannelAccessMessage
version
- protocol version to stay compatible with. This is the protocol
version of the peer the message is sent to.maxPayloadSize
- maximum size of the payload.charset
- encoding to use for serializing the string data (e.g. channel
names, error strings, string data-values).protected static ChannelAccessSearchUDPServerMessage deserialize(ChannelAccessMessageHeader messageHeader, ByteSource byteSource, Inet4Address originatingServerAddress, int originatingServerPort)
ChannelAccessMessageCodec
.messageHeader
- CA message header.byteSource
- byte source for reading the message's payload (if any).originatingServerAddress
- IP address of the server that sent this message.originatingServerPort
- UDP port of the server that sent this message.BufferUnderflowException
- if there is not enough data in the byte source to read the
complete payload.Copyright © 2014–2016 aquenos GmbH. All rights reserved.