Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread simple example of TServerRequestQueue ?
Fri, Sep 12 2014 12:38 PMPermanent Link

Bruno Larochelle

I am trying to understand how to use TServerRequestQueue

Can someone provide a few hints?

I know that I need to 'getNewRequest' and then 'addNewRequest'

But for the life of me I can't understand how to 'trigger' the requests using the 'queue'.

(I've used TServerRequest before.. I now want to serialize a few of them.. hence uses of the queue)

many thanks in advance

Bruno Larochelle
Logiciels Bitwise Software
Fri, Sep 12 2014 1:18 PMPermanent Link

Walter Matte

Tactical Business Corporation

I cut this example out of example posed here:

http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_demos&page=1&msg=38#38


Function TForm1.Doregister(email,Mypass,company,contact,telephone:String):Boolean;
Var
  MyLogin : String;
  MyPassword : String;
  MyServerRequest : TServerRequest;
begin
  Result:=True;
  MyserverRequest:=RequestQueue.GetNewRequest;
  with MyServerRequest do
  begin
     Myserverrequest.ResponseContent.LineSeparator:=#13+#10;
     Myserverrequest.OnComplete:=RequestComplete;
     URL := 'register-exec.php';
     RequestHeaders.Values['Content-Type'] := 'multipart/form-data; boundary=AaB03x';
     with RequestContent do
     begin
     Add('--AaB03x');
     Add('Content-Disposition: form-data; name="email"');
     Add('');
     Add(email);
     Add('--AaB03x');
     Add('Content-Disposition: form-data; name="password"');
     Add('');
     Add(MyPass);
     Add('--AaB03x');
     Add('Content-Disposition: form-data; name="company"');
     Add('');
     Add(Company);
     Add('--AaB03x');
     Add('Content-Disposition: form-data; name="contact"');
     Add('');
     Add(Contact);
     Add('--AaB03x');
     Add('Content-Disposition: form-data; name="telephone"');
     Add('');
     Add(telephone);
     Add('--AaB03x');
     end;


     Method := rmPost;
     //RequestQueue:=TServerRequestQueue.Create(nil);
     RequestQueue.AddRequest(MyserverRequest);
     // Execute;
  end;    

end;

Walter
Fri, Sep 12 2014 2:02 PMPermanent Link

Bruno Larochelle

thanks Walter for the prompt response

what still eludes me somewhat is 'what triggers the requests?'

in the example, the '.execute' is remmed out .. presumably gets done elsewhere in the code

the queue has several requests, presumably, so how do I get them to start .. by calling the 'execute' on any one of them that is in the queue? Or do I call 'execute' on all of them -- and that they individually will only execute if the prior one in the list is done?

I guess I would have expected that 'TServerRequestQueue' would have had a method to 'execute' once it is populated with requests. But it has no methods.

I will continue experimenting. Once I understand, I will go 'ahhhhh' Smile

Bruno

//

Walter Matte wrote:

I cut this example out of example posed here:

http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_demos&page=1&msg=38#38
Fri, Sep 12 2014 3:01 PMPermanent Link

Walter Matte

Tactical Business Corporation

There is an example in the Help too....   - while not explicitly stated and I have not tried the TServerRequestQueue - I would think it executes upon the AddRequest() - meaning if it is the first in the queue it executes it and when it is done, if there are more they get executed.

Walter

Bruno Larochelle wrote:

thanks Walter for the prompt response

what still eludes me somewhat is 'what triggers the requests?'

in the example, the '.execute' is remmed out .. presumably gets done elsewhere in the code

the queue has several requests, presumably, so how do I get them to start .. by calling the 'execute' on any one of them that is in the queue? Or do I call 'execute' on all of them -- and that they individually will only execute if the prior one in the list is done?

I guess I would have expected that 'TServerRequestQueue' would have had a method to 'execute' once it is populated with requests. But it has no methods.

I will continue experimenting. Once I understand, I will go 'ahhhhh' Smile

Bruno

//

Walter Matte wrote:

I cut this example out of example posed here:

http://www.elevatesoft.com/forums?action=view&category=ewb&id=ewb_demos&page=1&msg=38#38
Fri, Sep 12 2014 3:37 PMPermanent Link

Bruno Larochelle

thanks again Walter, I had not noticed there was more to the example (needed to scroll down), and it indeed looks like it works as you suggest. A the snippet (from the EWB help) shows:

procedure TMyForm.GetCustomerClick(Sender: TObject);
var
  TempRequest: TServerRequest;
begin
  TempRequest:=MyRequestQueue.GetNewRequest;
  TempRequest.URL:='/customer';
  TempRequest.Params.Add('method=info');
  TempRequest.ResponseContent.LineSeparator:=#10;
  TempRequest.OnComplete:=RequestComplete;
  MyRequestQueue.AddRequest(TempRequest);
end;

So, then .. ahhhhh! Smile

.. Bruno


Walter Matte wrote:

There is an example in the Help too....   - while not explicitly stated and I have not tried the TServerRequestQueue - I would think it executes upon the AddRequest() - meaning if it is the first in the queue it executes it and when it is done, if there are more they get executed.

Walter
Image