Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 19 of 19 total
Thread Calling RTC remote functions
Mon, May 14 2012 9:48 AMPermanent Link

Leslie

Raul,

Tim's JSon Dataset is probably enough for RPC in most cases. It is easy to work with and uses significantly less memory then XMLRPC. I will use XMLRPC only as last resort. RTCFunctions seem to handle only RTC's own format and XMLRPC, and the responce is the same format.  On the server side a little modified DataProvider can be used in almost the same manner as functions to create any kind of response. For now JSON  seems good enough. Later on we might switch to our own  more optimized format.

Cheers,
Leslie
Mon, May 14 2012 1:43 PMPermanent Link

Manfredt

Leslie wrote:

Raul,

> RTCFunctions seem to handle only RTC's own format and
> XMLRPC, and the responce is the same format.

The latest version of RTC, version 5.14, can
handle JSON+REST.

Regards,
Manfredt Kavetu
Mon, May 14 2012 3:29 PMPermanent Link

Leslie

Manfredt wrote:

<<The latest version of RTC, version 5.14, can
handle JSON+REST. >>

Checked with the latest starter edition and I do not see yet how. TRtcServerModule.DataFormats offers only  RTC and XMLRPC. Could not find any demo with having the string "JSON"  anywhere in the source.

Cheers,
Leslie
Mon, May 14 2012 7:05 PMPermanent Link

Manfredt

Leslie wrote:

<<Checked with the latest starter edition and I do not see yet how. TRtcServerModule.DataFormats offers only  RTC and XMLRPC. Could not find any demo with having the string "JSON"  anywhere in the source. >>

Check this link:
http://www.realthinclient.com/files/updates.html

Regards,
Manfredt
Tue, May 29 2012 2:29 AMPermanent Link

thomh

Hi Leslie,

Did you get the communication working effectively between EWB and RTC?

If so, any chance you can upload a small example of how this is done?

Any help to get started would be appreciated.

Thanks in advance.

// Thom
Sun, Dec 30 2012 1:08 PMPermanent Link

thomh

Hi All,

Did anybody ever the communication working effectively between EWB and RTC?

If so, any chance you can upload a small example of how this is done?

Any help to get started would be appreciated.

Thanks in advance.

// Thom
Mon, Dec 31 2012 5:42 AMPermanent Link

Walter Matte

Tactical Business Corporation

I did not use RtcFunctions.

Yes drop on two components and code 2 methods and you have a working Http Server.  Now the heavy lifting ... interogate the requests and formulate responses.

Use RtcHttpServer component and link a RtcDataProvider.

Here is some sample code which dumps what is coming in - to see the "request":

OnCheckRequest - confirm you want this component to receive the request and handle the response.
OnDataReceived -

procedure TForm1.RtcDataProvider3CheckRequest(Sender: TRtcConnection);
begin

 // Accept anything.....
 // Normally you would be looking for a specific Filename...
 with Sender as TRtcDataServer do   
 begin
   Accept;
 end;  

end;

procedure TForm1.RtcDataProvider3DataReceived(Sender: TRtcConnection);
var
 i : integer;
begin
 with Sender as TRtcDataServer do
 begin

   if (Request.Method='GET') then
   begin
     if Request.Complete then
     begin
       if Request.Query.ItemCount > 0 then
       begin
         memo1.lines.Add('GET' + #13#10+ Request.Query.Text);
       end;
       Memo1.Lines.add('');
       Memo1.Lines.Add(Request.Method + ' ' + Request.FileName);

       {
           Now take the request and parameters and do the work.... and formulate a reponse and send it
           back in the write statement....
       }

       write('I received the GET  ');    //  <<<<< Respond Back....
     end;
   end
   else
   begin
     Request.Params.AddText(Read);
     if (Request.Complete) then
     begin
       
       if Request.Params.ItemCount > 0 then
       begin
         memo1.lines.Add('POST '+ #13#10 + Request.Params.Text + #13#10 +
                             'ContentType ' +  Request.ContentType + #13#10 +
                             'ContentLength ' + IntToStr(Request.ContentLength));
                             
         memo1.Lines.Add(Request.ToString);
         
         for i := 0 to Request.Params.ItemCount - 1 do
         begin
           memo1.lines.Add(Request.Params.ItemName[i] + ' <=> ' + Request.Params.ItemValue[i]);
         end;
       end;
     
       Memo1.Lines.add('');
       Memo1.Lines.Add('3' +Request.Method + ' ' + Request.FileName);
         memo1.lines.Add('POST '+ #13#10 + Request.Params.Text + #13#10 +
                             'ContentType ' +  Request.ContentType + #13#10 +
                             'ContentLength ' + IntToStr(Request.ContentLength));

        write('Response to post....);   // <<  Respond back  
     end;
   end;           
 end;  

end;


// ---------------------------------------------------------------------
Another Example:

I'm checking for /DATASET/
This is what EWB sends when you do a Database.Load(MyDataset);

I wrote 2 functions - one to respond to SQL Queries and one to respond to Table requests
My queries always start with the name QRY - hence the test.  The function EWBGetQuery executes the query and returns the JSON.  Only my Name "QRYXXX' and parameters are sent
         Write(RtcString(Conn.EWBGetQuery(sTable, Request.Query)));

The is EWB code asking for a Query.
procedure TfrmDonorSearch.imgSearchBtnClick(Sender: TObject);
begin
 QryDonorSearch1.Params.Clear;
 if edOrg.Text > '' then
   QryDonorSearch1.Params.Add('Organization='+Uppercase(edOrg.Text));
 if edLN.Text > '' then
   QryDonorSearch1.Params.Add('LastName='+Uppercase(edLN.Text));
 if edFN.Text > '' then
   QryDonorSearch1.Params.Add('FirstName='+Uppercase(edFN.Text));

 if QryDonorSearch1.Params.Count = 0 then
   ShowMessage('Set Search Criteria')
 else
   Database.Load(QryDonorSearch1);
end;

The second function EWBGetData - expects a Table and and possible filter and sends back all fields and all data or filtered data in JSON.

         Write(RtcString(Conn.EWBGetData(sTable, sFilter)));


// Here are the two DataProvider Functions....


procedure TdmBasicDonorServer.dbDataCheckRequest(Sender: TRtcConnection);
begin
 with Sender as TRtcDataServer do
 begin
   if Copy(Uppercase(Request.FileName),1,9) = '/DATASET/' then
     Accept;
 end;  

end;

procedure TdmBasicDonorServer.dbDataDataReceived(Sender: TRtcConnection);
var
 Conn : IDBISAMPool;
 sTable : string;
 sFilter : string;                  
begin
 with Sender as TRtcDataServer do
 begin
   if Request.Complete then
   begin
     sTable := Copy(Request.FileName,10, length(Request.FileName) - 9);   // sTable will contain "MyDataset"
     Conn := FConnections.LockConnection;
     try
       if Copy(UpperCase(sTable),1,3) = 'QRY' then
       begin
         Response.HeaderText :=
           Response.HeaderText +
           // 'Cache-Control: must-revalidate, post-check=0, pre-check=0' + #13#10 +
           RtcString('Cache-Control: no-cache, no-store' + #13#10);
         Write(RtcString(Conn.EWBGetQuery(sTable, Request.Query)));
       end
       else
       begin
         sFilter := URL_Decode(Request.Query.Value['filter']);
         Response.HeaderText :=
           Response.HeaderText +
           // 'Cache-Control: must-revalidate, post-check=0, pre-check=0' + #13#10 +
           RtcString('Cache-Control: no-cache, no-store' + #13#10);
         Write(RtcString(Conn.EWBGetData(sTable, sFilter)));
       end;
     finally
       FConnections.UnlockConnection(Conn);
     end;
   end;
 end;  
end;



Walter


thomh wrote:

Hi All,

Did anybody ever the communication working effectively between EWB and RTC?

If so, any chance you can upload a small example of how this is done?

Any help to get started would be appreciated.

Thanks in advance.

// Thom
Thu, Jan 3 2013 8:28 AMPermanent Link

thomh

Hi Walter!

Thank you very much for the detailed response.

However, one problem I see is that Grid.Columns.Clear only clears the data from the grid and not the columns.
So when I build the dataset and grid at runtime with different JSON return data I am unable to clear the previous grid columns.

Can you confirm this?

// Thom
Thu, Jan 3 2013 9:40 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Thom,

<< However, one problem I see is that Grid.Columns.Clear only clears the
data from the grid and not the columns. So when I build the dataset and grid
at runtime with different JSON return data I am unable to clear the previous
grid columns.

Can you confirm this? >>

Yes, I can confirm this behavior.  I'll have a fix for it in the next build.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image