RTC Forums
November 24, 2024, 09:59:13 PM *
Welcome, Guest. Please login or register.

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


« on: February 22, 2012, 03:42:42 PM »

Hi Danijel

Yup, it's me again :-(

Re: HTTPClient requests

OK, I have now been working on your advice and each server has its own dedicated client. I now need to be able to 'chain' the requests, one after the other. Remember I suggested an input repository for the request.info command? I need to know what to look for if using multi-threading to check a client is ready to make the new request after a previous one. I still have not 'got' the event sequence properly, as i said, a visual representation of this would be great for me, as this is how I see things. But and ...

So ...

> Do request 1
when done
process request
when done? Perhaps not necessary, as the client thread for the second request is ready anyway?

> Do request 2
when done
process request
when done

> Do request 3
when done
process request


Please could you indicate how this is done without error.

TIA

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


« Reply #1 on: February 22, 2012, 03:59:22 PM »

The OnResponseDone event will fire on the TRtcDataRequst component after a full response was received from the Server. From there, you can prepare and post a new request.

PS. RTC SDK uses events for all kinds of notifations, and each event is explained in the help file as well as component/class declaration (see source code comments).

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 on: February 22, 2012, 04:09:18 PM »

Also check the "OnResponseAbort" event, which will be fired in case a request or a response were aborted. By using "OnResponseDone" and "OnResponseAbort" events, you can implement request chains, even if you don't know where each request should be sent to.

Another solution for implemeting "chaining requests" to a specific Server (when Address and Port aren't changing between requests) is to post all request(s) immediately when you "have" them. This will place each posted request into a request queue and processes one request after another.

Best Regards,
Danijel Tkalcec
Logged
jonb2
Newbie
*
Posts: 36


« Reply #3 on: February 22, 2012, 04:26:38 PM »

Thanks D.

I am sorry, but i want to be clear ...

So a series of while loops for "OnResponseDone" and a 'completed' reference from each 'process request' procedure. The reason I ask is that because it's an asynchronous progress, the IF statement won't work for a sequence?

I still think a visual diagram would help for idiots like me :-)

J

PS.
Just read "Another solution for implemeting "chaining requests" to a specific Server (when Address and Port aren't changing between requests) is to post all request(s) immediately when you "have" them" <<< I think this is what I was saying above.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 on: February 22, 2012, 04:33:54 PM »

Maybe you mean something else with while loops for "OnResponseDone", but I just want to make clear that there are no "while" loops in the RTC SDK, because the components are fully event-driven. The "OnResonseDone" event will be triggered after a complete response is received, while the "OnResponseAbort" event signals that a request/response chain was abborted (connection problems).

But I guess you already have the solution you were looking for. Simply use "Post" to fill a request queue and let the component handle "chaining" of requests inside the queue. You can post a new request at any time, even while other requests are currently being processed. The request will then simply be added to the end of the request list and processed once all the other requests from the list are done.

Best Regards,
Danijel Tkalcec
Logged
jonb2
Newbie
*
Posts: 36


« Reply #5 on: February 22, 2012, 04:45:08 PM »

Thank you D. I think I might 'just' scrape a pass in this now.
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.025 seconds with 17 queries.