[DUG] Automation types and blobs
Conor Boyd
Conor.Boyd at trimble.co.nz
Wed May 31 16:46:01 NZST 2006
In theory it would work with a VB client etc, but on the understanding
that the VB code that does the unstreaming would need to know intimately
the structure of the byte arrays being passed.
I suppose we're lucky in that our client and server are both Delphi, so
we just compile the streaming classes into both projects and it just
works.
The other thing to point out about streaming using byte arrays is that
it's not version-safe (e.g. you change the format of your internal byte
arrays being streamed and every client will need to know about it).
We're safe because our server and clients are always in sync, but it's
something to be aware of.
Not sure I understand the second part of your email, but that may just
be me being stupid.
C.
-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz]
On Behalf Of Phil Middlemiss
I didn't realise variant arrays were automation compatible - the help
doesn't indicate this. Would this work for a VB or C++ client app?
I'm wondering if I can shortcut the whole thing though - I have an
automation interface that represents, say, a polygon. Since the client
code still has to formulate a variant array (to pass to the
TStreamable), why not just pass the variant array to the polygon
interface?
eg, IMyPolygon.AddPoints(Points : OleVariant);
Cheers,
Phil.
Conor Boyd wrote:
> Look into creating some sort of streaming framework.
>
> E.g.
>
> Have a base TStreamable class.
>
> Then declare "transport" type classes for each item of data you want
> to pass between client and server.
>
> Have your base TStreamable class know how to take a stream and turn it
> into an OleVariant.
>
> Have each of your transport classes implement a ReadFromStream and
> SaveToStream method which writes the internal values of the object to
> the stream.
>
> E.g.
>
> Tstreamable = class
> Public
> procedure ReadFromStream(Stream: Tstream); virtual;
> procedure WriteToStream(Stream: Tstream); virtual;
>
> function ToVariant: OleVariant;
> procedure FromVariant(vrnt: OleVariant); End;
>
> TMyInfo = class(Tstreamable)
> Private
> FSomeInfo: String;
> FSomeOtherInfo: Tpoint;
> Public
> procedure ReadFromStream(Stream: Tstream); override;
> procedure WriteToStream(Stream: Tstream); override;
>
> property SomeInfo: String read FSomeInfo write FSomeInfo;
> property SomeOtherInfo; Tpoint read FSomeOtherInfo write
> FSomeOtherInfo; End;
>
> Your TMyInfo class knows how to read and write it's internal fields
> to/from a Tstream.
>
> Your code that wants to send that info between client and server calls
> ToVariant and FromVariant on the TMyInfo class and sends the
OleVariant.
>
> The ToVariant and FromVariant methods need to take a Tstream and turn
> it into a VarArray of type varByte, which is the actual OleVariant
> that gets transported.
>
> I wrote this at some speed, so not sure if it'll make 100% sense
> straight off. Let me know if you want more specifics or some sample
> code.
>
> I use this type of framework for transporting classes, records,
> arrays, etc. You can chain this type of stuff together so that
> complex objects in turn use the ReadFromStream/WriteToStream methods
> on internal fields as appropriate.
>
> HTH,
>
> Conor
>
> -----Original Message-----
> From: delphi-bounces at ns3.123.co.nz
> [mailto:delphi-bounces at ns3.123.co.nz]
> On Behalf Of Phil Middlemiss
>
> Having read the help about which data types are automation compatible,
> it seems there is no quick way to send a chuck of memory to an
> automation object: The only option I can see is to send the data
> integer by integer (if I'm sending TPoint then send X and Y for every
point).
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
>
>
More information about the Delphi
mailing list