RTC Forums

Subscription => Support => Topic started by: ISIGest on May 02, 2015, 10:45:32 AM



Title: Continuos WriteEx in DataReceived Event
Post by: ISIGest on May 02, 2015, 10:45:32 AM
So, I've an RtcHTTPServer and I need to send continuos data to client afer a request.
I've in CheckRequest event accepted the request and I'va call WriteHeader(True);
In OnDataReceived event I've an infinite while that check the buffer and when buffer have data call the "WriteEx" procedure...
All work fine but the client does not receive any data. So, I try to call Flush metod to force write into connection and after this I clear the response (Response.Clear) to re-calculate content length but after first step I got an exception and the connection will be lost.
Can you help me please?

P.S.
I need to make a data flow like a streaming.


Title: Re: Continuos WriteEx in DataReceived Event
Post by: D.Tkalcec (RTC) on May 02, 2015, 11:17:56 AM
You are trying to force the components to do something they weren't designed for. When sending large amounts of data, you have to split your code to react on the OnDataReceived and OnDataSent events. Do NOT try to write a continuous loop with WriteEx inside the OnDataReceived events, because that will only flood the memory buffers and won't start sending anything out until the event is finished. If you need an example of a correct Server implementation where large amounts of data are being sent out, check Quick Start Server lessons. Especially the Server Lesson 4, which shows you how to send large files by using the WriteEx method to start the sending process and then use the OnDataSent event to continue, until the whole file is sent.

Best Regards,
Danijel Tkalcec


Title: Re: Continuos WriteEx in DataReceived Event
Post by: ISIGest on May 02, 2015, 01:40:26 PM
All work very very well...Thank you