Page 1 of 1

HTTPRequest return order

Posted: Mon Nov 06, 2017 1:09 pm
by karu
I make requests:

HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=1", @HttpGetEvent())
HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=2", @HttpGetEvent())
HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=3", @HttpGetEvent())
HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=4", @HttpGetEvent())

depends server load, files may come in other order, example:
3
1
2
4

If i make several queries in succession, the files(answers) from servers may come in other order. How i can make http request command, that
not return until file is received. Or is there some other method to receive files in right order?
Shortly, i need synchronous query, is that possible?

Thanks
Raimo

Re: HTTPRequest return order

Posted: Mon Nov 06, 2017 2:08 pm
by karu
I resolved this question with making my own buffer, that will not send next message, until lastone returned

Re: HTTPRequest return order

Posted: Mon Nov 06, 2017 2:09 pm
by Peter
perhaps like this way (untested):

Code: Select all

Procedure HttpGetEvent(...

  Static nbRequests = 1

  [YourCode]

  nbRequests + 1

  If nbRequests < 5
    HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=" + Str(nbRequests), @HttpGetEvent())
  EndIf
	
EndProcedure

HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=1", @HttpGetEvent())
Greetings ... Peter