public final class ChannelAccessSubscriptionClientMessage extends ChannelAccessSubscriptionMessage
CA_PROTO_EVENT_ADD
message that is sent from
a client to a server. This message is sent in order to subscribe to events
for a channel.ChannelAccessCommand.CA_PROTO_EVENT_ADD
,
ChannelAccessSubscriptionServerMessage
,
ChannelAccessCancelSubscriptionServerMessage
command, originalMessageHeader
Constructor and Description |
---|
ChannelAccessSubscriptionClientMessage(ChannelAccessValueType dataType,
int count,
int sid,
int subscriptionId,
ChannelAccessEventMask mask)
Creates a
CA_PROTO_EVENT_ADD message. |
Modifier and Type | Method and Description |
---|---|
protected static ChannelAccessSubscriptionClientMessage |
deserialize(ChannelAccessMessageHeader messageHeader,
ByteSource byteSource,
boolean headerOnly)
Constructs a message from a header and a byte source.
|
boolean |
equals(java.lang.Object obj)
Tells whether the specified object represents the same message.
|
int |
getChannelSID()
Returns the channel SID.
|
int |
getCount()
Returns the number of elements of the value that should be sent in
subscription events.
|
ChannelAccessValueType |
getDataType()
Returns the data-type requested for the subscription.
|
ChannelAccessEventMask |
getMask()
Returns the event mask for this subscription.
|
int |
getSubscriptionId()
Returns the client-assigned subscription ID.
|
int |
hashCode()
Returns a hash code value for this message.
|
protected void |
serialize(ByteSink byteSink,
ChannelAccessVersion version,
int maxPayloadSize,
java.nio.charset.Charset charset)
Serializes this message to a byte sink.
|
java.lang.String |
toString()
Returns a string representation of this message.
|
protected void |
verify(ChannelAccessVersion version,
int maxPayloadSize,
java.nio.charset.Charset charset)
Verifies that this message can be serialized.
|
addByteArrayToStringBuilder, calculatePaddingSize, getCommand, getOriginalMessageHeader, hasOriginalMessageHeader, serializeHeader, verifyHeader
public ChannelAccessSubscriptionClientMessage(ChannelAccessValueType dataType, int count, int sid, int subscriptionId, ChannelAccessEventMask mask)
CA_PROTO_EVENT_ADD
message. This constructor
should be used to create a message that is supposed to be sent from a
client to a server.dataType
- requested data-type for the subscription. The server should
send notifications with this data type.count
- the number of value elements to send in notifications. Must
not be larger than the channel's native element count. May
only be zero for Channel Access version 4.13 and newer. In
this case, a value of zero indicates to use the channel's
native count.sid
- server-assigned ID identifying the channel.subscriptionId
- client-assigned ID identifying the subscription. This ID will
be sent with events so that the client can identify the
subscription to which the event belongs.mask
- event mask to use for the subscription. A subscription will
only receive events which have an event mask that has at least
one bit set, that it also set in the subscription's event mask
(binary or).public ChannelAccessValueType getDataType()
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 getCount()
public int getChannelSID()
public int getSubscriptionId()
public ChannelAccessEventMask getMask()
public boolean equals(java.lang.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 java.lang.String toString()
ChannelAccessMessage
toString
in class ChannelAccessMessage
protected void serialize(ByteSink byteSink, ChannelAccessVersion version, int maxPayloadSize, java.nio.charset.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, java.nio.charset.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 ChannelAccessSubscriptionClientMessage deserialize(ChannelAccessMessageHeader messageHeader, ByteSource byteSource, boolean headerOnly)
ChannelAccessMessageCodec
.messageHeader
- CA message header.byteSource
- byte source for reading the message's payload (if any).headerOnly
- if true
this method will not try to read the
payload but just read the header. This is useful for reading a
message that is sent in the payload of a
ChannelAccessErrorMessage
. Such a message will have
all headers but no payload (even so the payload size might be
non-zero).headerOnly
is
false
).java.nio.BufferUnderflowException
- if there is not enough data in the byte source to read the
complete payload.ShortPayloadException
- if the message's payload size is less than 16 bytes and
headerOnly
is false
.Copyright © 2014–2017 aquenos GmbH. All rights reserved.