The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

xFx message reception and schemas


  • Subject: xFx message reception and schemas
  • From: Stuart Booth <lists@xxxxxxxxxxxxxxxx>
  • Date: Sat, 29 Oct 2005 19:19:48 +0100
  • References: <46e456080510251450o5df5efb8g@mail.gmail.com> <ECOWS02MnyBaT4ghriS0000336a@smtp-out2.blueyonder.co.uk> <46e456080510251648o4606b19bn@mail.gmail.com> <sg60m1t7br9o4uq4egrhm766f865ja3g55@4ax.com> <46e456080510271416h52a9e346n@mail.gmail.com> <4bh2m1lbu52m2acn8790j19gkf50papnm5@4ax.com> <46e456080510271642y25e55564l@mail.gmail.com>

On Fri, 28 Oct 2005 00:42:13 +0100, Simon McCaughey
<simonmcc@xxxxxxx> wrote:

> Next question : receiving the message at the other end - I instantiate
a
>xAPHubClientListener and handle the MessageReceived event. From that I
get
>the message and to retrieve the data in a safe way, I need to convert
it to
>a xAPSerialSendBlock object, which I do using the following code :
>
>if(message.Header.Class.ClassType == "Serial.Comms")
>{
>xAPMessageBlock xmb =
event_args.Message.Body.GetMessage("Serial.Send");
>if(xmb != null)
>{
>xAPSerialSendBlock block = new xAPSerialSendBlock(xmb);
[snip]
>}
>My question : is this correct? Or is there a better/safer way to do it?

That's certainly one of the ways I've taken to doing it. A specific
message block constructor can always read a generic message block,
validating the input ie pass a generic xAPMessageBlock instance to the
CTOR of xAPSerialSendBlock, and xAPSerialSendBlock will know what to
expect in the generic message block. If the generic message block
isn't well-formed according to xAPSerialSendBlock's view of the
schema, xAPSerialSendBlock will moan.

Some of the schema-specific message classes can actually read in an
entire generic xAPMessage instance (such as supplied in the message
received event arguments) and convert the message blocks to their
higher level equivalents.

But all that code is very boiler-plate and tedious to write so isn't
always complete until I find a need for it to be done. I'm sure
there's probably a better way of doing it.

> Or should I be using a xAPSerialReceivedBlock here instead?

No, an instance of xAPSerialSendBlock will have a block name of
"Serial.Send" which is what you expected to receive. Currently
the
content happens to be the same, but should that change in future,
using the correct schema wrapper class might well reduce any future
maintenance.

S
--
Stuart Booth <stuart@xxxxxxx>
xAPFramework.NET - a xAP software development framework for .NET

http://www.xapautomation.org/ 
     http://www.xapframework.net/



xAP_Development Main Index | xAP_Development Thread Index | xAP_Development Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.