RTC Forums
May 02, 2024, 12:37:44 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Streaming question  (Read 3350 times)
jonb2
Newbie
*
Posts: 36


« 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

Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 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
Logged
jonb2
Newbie
*
Posts: 36


« Reply #2 on: February 07, 2012, 09:08:49 AM »

Thanks D.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 17 queries.