Interfaces
Last updated
Was this helpful?
Last updated
Was this helpful?
There are protocols that attach some extra information, such as version and/or extra flags, to the message transport . This extra information usually influences how message fields are deserialized and/or how message object is handled. It means that these received extra values need to be attached to every message object. The CommsDSL allows specification of such extra information as <interface> XML element with extra .
The code generator may use provided information to generate common interface class(es) for all the messages. Such class will serve as base class of every message object and will contain required extra information.
NOTE that specified fields, are NOT part of every message's payload. These fields are there to hold extra values delivered as part of message .
Every interface definition must specify its using name .
Sometimes different interfaces have common set of fields. In order to avoid duplication, use copyFieldsFrom property to specify original interface and then add extra fields when needed.
In the example above Interface2 will have 2 fields: "Version" and "Flags".
If the protocol doesn't have any extra values delivered in message framing, then the whole definition of the <interface> XML element can be omitted. If no <interface> node has been added to the protocol schema, then the code generator must treat schema as if the schema has implicit definition of the single <interface> with no fields. It is up to the code generator to choose name for the common interface class it creates.
It is possible to provide a description of the interface about what it is and how it is expected to be used. This description is only for documentation purposes and may find it's way into the generated code as a comment for the generated class. The is description.
Similar to <message> every <interface> has zero or more that can be specified as child XML elements. If there is any other defined as XML child of the <interface>, then all the fields must be wrapped in <fields> XML element for separation.
NOTE usage of semanticType="version" for the field holding protocol version in the examples above. It is required to be used for proper . The value of the field having "version" value as semanticType property, will be considered for fields that, were introduced and/or deprecated at some stage, i.e. use sinceVersion and/or derecated + removed properties.
Sometimes an contained field may be renamed and/or moved. It is possible to create alias names for the fields to keep the old client code being able to compile and work. Please refer to chapter for more details.
Use for future references.