RTC Forums

Subscription => Support => Topic started by: jonb2 on February 06, 2012, 09:00:18 PM



Title: Streaming question
Post by: jonb2 on February 06, 2012, 09:00:18 PM
New at this, so please be patient :-)

I am using RTC client controls (httpclient/datarequest) as an API get/post interface to various web services. I have taken the http client demo and successfully got it working with returning data using just the serveraddr/host/ and .text parameters (no filename needed I think). The data is being shown in the memo, as per the demo. I would now really want to load the returned data into a stream (perhaps).

The returned data is a smorgasboard of Json, XML and plain multiline CSV - depending on which service I am talking to. So there is qute a lot of condtional post-processing. I think that rtcByteStream will be the fastest choice as a universal stream for this. Am I right? If so - please could you supply a code snippet which substitutes the memo for the stream. I can't seem to get my head around it.

In other words, the question is how to move received data into an optimal state for further string processing. Simply, how do I get the returned data into a stream

TIA

Jon



Title: Re: Streaming question
Post by: D.Tkalcec (RTC) on February 06, 2012, 09:12:28 PM
Since you are using the TRtcDataRequest component, you will get the data as AnsiString when using the "Read" method. This is what you already have working, since you are placing that data into a Memo. If you want to copy that AnsiString (returned from the "Read" method) into a TStream, the "TStringStream" class from Delphi should do the trick. For more information on using the TStringStream class ("Classes.pas" unit in the Delphi RTL), please reffer to Delphi HELP files.

PS. You can wait for "TRtcDataClient(Sender).Response.Done" to return TRUE before you use the "Read" method, then you will get the complete response content in a single AnsiString when using the "Read" method (no need to manually contatenate it).

Best Regards,
Danijel Tkalcec


Title: Re: Streaming question
Post by: jonb2 on February 07, 2012, 09:08:49 AM
Thanks D.