public final class ChannelAccessConnectChannelServerMessage extends ChannelAccessConnectChannelMessage
CA_PROTO_CREATE_CHAN
message that is sent
from a server to a client. This message is sent in order to acknowledge the
connection of a channel and give the client information about the channel.
Multiple channels can be connected within the same TCP connection.ChannelAccessCommand.CA_PROTO_CREATE_CHAN
,
ChannelAccessConnectChannelClientMessage
command, originalMessageHeader
Constructor and Description |
---|
ChannelAccessConnectChannelServerMessage(int cid,
int sid,
ChannelAccessValueType dataType,
int count)
Creates a
CA_PROTO_CREATE_CHAN message. |
Modifier and Type | Method and Description |
---|---|
protected static ChannelAccessConnectChannelServerMessage |
deserialize(ChannelAccessMessageHeader messageHeader,
ByteSource byteSource)
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 CID used by the client.
|
int |
getChannelSID()
Returns the channel SID used by the server.
|
int |
getNativeCount()
Returns the native count of this channel.
|
ChannelAccessValueType |
getNativeDataType()
Returns the native data-type of this channel.
|
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 ChannelAccessConnectChannelServerMessage(int cid, int sid, ChannelAccessValueType dataType, int count)
CA_PROTO_CREATE_CHAN
message. This constructor
should be used to create a message that is supposed to be sent from a
server to a client.cid
- channel CID used by the client. This is the identifier that
the client will use to identify the channel in the response
from the server. This number might be negative or zero.sid
- channel SID used by the server. This is the identifier that
the server will use to identify the channel in monitor, read
or write requests from the client. This number might be
negative or zero.dataType
- the native data-type of the channel (never null
).
This is the data-type that can be processed by the server
without any conversion.count
- the native count of the channel. This is the number of
elements that the channel's value can have on the server. Read
or write operations to the channel cannot exceed this number
of elements. However, a client might decide to request less
elements.public int getChannelCID()
public int getChannelSID()
public ChannelAccessValueType getNativeDataType()
null
if the specified data-type is unknown to this implementation.null
if the
numeric identifier cannot be mapped to a data type known by this
implementation.public int getNativeCount()
Returns the native count of this channel. This is the number of elements that the channel's value has on the server. The value in read and write operations can never have more elements than this number. However, the client can choose to use a smaller number of elements.
If the channel has more than Integer.MAX_VALUE
elements, this
number can become negative. In this case, the true number of elements is
the returned number plus 2^32. However, channels with such a large number
of elements are not practical due to limitations of the Channel Access
protocol and thus should never appear in practice.
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).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 static ChannelAccessConnectChannelServerMessage deserialize(ChannelAccessMessageHeader messageHeader, ByteSource byteSource)
ChannelAccessMessageCodec
.messageHeader
- CA message header.byteSource
- byte source for reading the message's payload (if any).BufferUnderflowException
- if there is not enough data in the byte source to read the
complete payload.InvalidPriorityException
- if the priority specified in the message header is out of
range.Copyright © 2014–2016 aquenos GmbH. All rights reserved.