Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread TServerRequest "Commuting"
Fri, Mar 15 2013 6:43 AMPermanent Link

Mark Brooks

Slikware

Avatar

Hi All,

In a recent project I find myself communicating with a custom REST server, which is something that EWB handles extremely well.

However, there are certain scenarios where I need to perform a GET against a specific REST server URL and perform different actions on completion, based on the context within which the GET was instigated. Traditionally I would simply use a separate callback function based on context.

It strikes me that EWB could be extended to allow a TObject reference to be passed as part of a TServerRequest such that it could be referenced on completion of the request. The TObject reference could be used to pass all sorts of information which would effectively "commute" through the asynchronous call.

In my scenario above, I could use this to understand the context of a REST call on completion and therefore utilise a single callback function to handle all requirements against a specific RESET URL.

Thoughts / help appreciated?

Mark
Fri, Mar 15 2013 3:24 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< It strikes me that EWB could be extended to allow a TObject reference to
be passed as part of a TServerRequest such that it could be referenced on
completion of the request. The TObject reference could be used to pass all
sorts of information which would effectively "commute" through the
asynchronous call. >>

Every component, including TServerRequest components, have a Data property
(TObject) that allows you to attach an object reference to the component.
The TDataSet architecture in EWB uses this to indicate which dataset is
doing a load via a server request:

procedure TDatabase.Load(DataSet: TDataSet; Append: Boolean=False);
var
  TempRequest: TServerRequest;
  I: Integer;
begin
  DataSet.AppendLoad:=Append;
  TempRequest:=FRequestQueue.GetNewRequest;
  TempRequest.URL:=AddFS(FBaseURL)+DataSet.DataSetName;
  TempRequest.Params.Add('method=rows');
  for I:=0 to DataSet.Params.Count-1 do
     TempRequest.Params.Add(DataSet.Params[I]);
  TempRequest.Data:=DataSet; <<<<<<<<<<<<<<<<<<  Here
  TempRequest.OnComplete:=RequestComplete;
  if (FUserName <> '') and (FPassword <> '') then
     begin
     TempRequest.RequestHeaders.Values['X-EWBUser']:=FUserName;
     TempRequest.RequestHeaders.Values['X-EWBPassword']:=FPassword;
     end;
  FRequestQueue.AddRequest(TempRequest);
end;

Tim Young
Elevate Software
www.elevatesoft.com
Image