May be asking the obvious but is the Boo property of TNamMessageForComms
published and not read-only?  Which version of Delphi are you using?  Also,
is TNamMessageForComms a TComponent?

----- Original Message -----
From: "Donovan J. Edye" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Thursday, July 10, 2003 6:59 PM
Subject: [DUG]: [Q] Stream.ReadComponent, Stream.WriteComponent problem....


> G'Day,
>
> See below for the class declarations and the encode and decode methods
that
> I am using. I am not compressing anything so this should be a plain write
> component to a stream and read it back again. However when I read the
> component again from the stream I can only see properties that are from
> TNamMessageForComms so for instance I can see Boo2, Payload, Header. But
all
> the properties for these subcomponents are not there. So for instance
> Payload.Boo is always an empty string. What am I missing here that is not
> making the sub components of TNamMessageForComms stream correctly.
>
> Any pointers etc. greatly appreciated.
>
> TIA
>
>
> function TNamMessageForCommsEncDec.Encode(const ACompression :
> TCompressionRange;
>   const ASourceStream : TMemoryStream; var AOutputStream : TMemoryStream)
:
> TEncodeDecodeError;
>
////////////////////////////////////////////////////////////////////////////
> ////
> // PURPOSE: Encodes the supplied data into a stream for transmission. This
> // method is called by all the other overloaded methods of the same name.
It
> // makes use of the TNamMessageForComms
> // HISTORY:
> //   DJE 10/07/2003 #   Initial Creation
> begin
>   //Default behaviour
>   result := MSG_DECODE_ERR_UNKNOWN;
>   AOutputStream.Clear;
>
>   //Header
>   FMessage.Header.MessageType := MSG_REGULAR;
>
>   //Payload
>   //Clear
>   FMessage.Payload.Data_Clear;
>   //Compression
>   FMessage.Payload.Compressed := ACompression;
>   //Assign
>   FMessage.Payload.Data_Set(ASourceStream);
>
>   //Now place on the output stream
>   AOutputStream.WriteComponent(FMessage);
>
>   //Show success
>   result := MSG_DECODE_ERR_NONE;
> end;
>
> function TNamMessageForCommsEncDec.Decode(ASourceStream : TMemoryStream;
>   var AOutputStream : TMemoryStream) : TEncodeDecodeError;
>
////////////////////////////////////////////////////////////////////////////
> ////
> // PURPOSE: Decodes a byte stream that was placed into the source stream
> // originally by Encode.
> // HISTORY:
> //   DJE 10/07/2003 #   Initial Creation
> begin
>   //Default behaviour
>   result := MSG_DECODE_ERR_UNKNOWN;
>   AOutputStream.Clear;
>
>   //First get the component in its entirey
>   ASourceStream.Position := 0;
>   FMessage := TNamMessageForComms(ASourceStream.ReadComponent(nil));
>
>   //Decompress it if required
>   //The class is optomised to deal with this assignment so there is no
> performance
>   //penalty
>   FMessage.Payload.Compressed := COMPRESSION_NONE;
>
>   //Now return the payload ontothe stream supplied
>   AOutputStream.Write(FMessage.Payload.Data,
SizeOf(FMessage.Payload.Data));
>
>   //Show success
>   result := MSG_DECODE_ERR_NONE;
> end;
>
>
> initialization
>   RegisterClass(TNamMessageForComms);
>   RegisterClass(TNamMessageForCommsHeader);
>   RegisterClass(TNamMessageForCommsPayload);
> finalization
>   UnRegisterClass(TNamMessageForComms);
>   UnRegisterClass(TNamMessageForCommsHeader);
>   UnRegisterClass(TNamMessageForCommsPayload);
> end.
>
>
>   ENamMessageForCommsHeader = class(Exception);
>   TNamMessageForCommsHeader = class(TComponent)
>
>
////////////////////////////////////////////////////////////////////////////
> //
>     // This class contains all the META or header information for a
> particular
>     // message. See TNamMessageForComms for more detail on why we are
using
> a
>     // TComponent descendant. Keep this as small as possible as it will be
> prepended
>     // to each message sent.
>   private
>     FMessageType : TMessageType;        //Indicates the type of message
>     property MessageType : TMessageType read FMessageType write
> FMessageType;
>   published
>   end;
>
>   //Byte stream containing the data
>   TPlayloadData = array of byte;
>
>   ENamMessageForCommsPayload = class(Exception);
>   TNamMessageForCommsPayload = class(TComponent)
>
>
////////////////////////////////////////////////////////////////////////////
> //
>     // This class contains all the data payload for a message. See
> TNamMessageForComms
>     // for more detail on why we are using a TComponent descendant
>   private
>     FBoo : string;
>     FCompressed : TCompressionRange;
>     FData : TPlayloadData;
>     FZipper : TVCLZip;
>     FZipTmpFileName : TFileName;
>     procedure Set_Compressed(const Value : TCompressionRange);
>     function Stream_Compress(ACompressionLevel : TCompressionRange; const
> AOriginalStream : TMemoryStream;
>       var ACompressedStream : TMemoryStream) : boolean;
>     function Stream_DeCompress(const AOriginalStream : TMemoryStream;
>       var ADeCompressedStream : TMemoryStream) : boolean;
>     function Stream_ToDataInternal(AStream : TMemoryStream) : boolean;
>   public
>     constructor Create(AOwner : TComponent); override;
>     destructor Destroy; override;
>     procedure Data_Clear;
>     procedure Data_Set(const AStream : TMemoryStream);
>     property Compressed : TCompressionRange read FCompressed write
> Set_Compressed;
>   published
>     property Data : TPlayloadData read FData;
>     property Boo : string read FBoo;
>   end;
>
>   ENamMessageForComms = class(Exception);
>   TNamMessageForComms = class(TComponent)
>
>
////////////////////////////////////////////////////////////////////////////
> //
>     // This is the structure that is used to manage a message that is
> transmitted
>     // and received by the NamMessage framework. We are using a TComponent
>     // descendant deliberately here as we can use Delphi's built in
> streaming
>     // mechanism to place this class onto and off a stream. Consequently
all
> things
>     // we want to be able to stream must be declared as publihed
>   private
>     FHeader : TNamMessageForCommsHeader;
>     FPayload : TNamMessageForCommsPayload;
>     FBoo2: string;
>   public
>     constructor Create(AOwner : TComponent); override;
>     destructor Destroy; override;
>   published
>     property Boo2 : string read FBoo2 write FBoo2;
>     property Header : TNamMessageForCommsHeader read FHeader;
>     property Payload : TNamMessageForCommsPayload read FPayload;
>   end;
>
> -- Donovan J. Edye
> ----------------------------------------------------------------------
> Namadgi Systems
> Voice: +61-2-6285-3460
> Fax: +61-2-6285-3459
> ----------------------------------------------------------------------
> SetiStats - Get your SETI statistics delivered to your mailbox daily.
> http://www.edye.wattle.id.au/p.php?page=/delphi/setistats
> <http://www.edye.wattle.id.au/p.php?page=/delphi/setistats>
> ----------------------------------------------------------------------
>
>
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to