commsdsl
commsdsl copied to clipboard
Select variant based on value in the transport frame
I am modeling a protocol that contains a request-reply pattern, where the payload of the reply can only be identified by an identifier that the clients puts into the transport frame of the request. In other words, I can decode the reply based on information that is ony known by the client and echoed by the the server.
I first did some manual decoding of the payload, but then I end up doing the same stuff where comms is the champ ;-) So, I modeled that as well in commsdsl, in the form:
<variant>
<bundle/>
<bundle/>
<bundle/>
</variant>
I studied the commsdsl manual and tutorial4 of the cc_tutorials. However, me payload has no key to identify what variant to select. I tried the following two approaches, but failed to get it to work:
- Insert a 'pseudo' key into the bundles with a 'validValue' identical to the key that is found in the transport frame value. Then copy the transport frame value into the pseudo element during dispatching and then rely on the 'currentFieldExec' method as done in tutorial4.
- Insert a 'pseudo' key into the bundled with a 'defaultValue'. Then iterate over all members of the variant during dispatching and compare the transport frame value to each defaultValue. Keep the member field selected that matches with the transport frame value.
Before this I modeled this variant with a sequence of 'optional' fields. While this is conceptually wrong, it did work because in the condition I can refer to the transport frame value.
I hope somebody could point me in the right direction. Should I stick with the 'variant' or go with the 'optional' values? If 'variant' is the way to go, how can I ensure that the variant member is selected based on information in the transport frame?