RTC Forums

Subscription => Support => Topic started by: Jose Carlos on November 14, 2012, 08:09:28 PM



Title: Sending all table data from client to server
Post by: Jose Carlos on November 14, 2012, 08:09:28 PM

 I have an iOS application that receive data from a rtcHttpserver and copy them into sqlite tables, I use the sample FischFact to get this done and it is working.

  On the server side I have a rtcFunction and I did this:
    DelphiDataSetToRtc(qryData, Result.NewDataSet); // qryData have all data I want to send to client.


  I want now, send tables back to the server, all data. My application works disconected from the server.

The FishFact demo uses RtcMemDataSet1.ExtractChanges, but what I need is, open the table and send all data to the server.

 I know that I need a another rtcFuntion to submit the table.

 Are there any rtc demos showing this? Or you can show me how.

Thanks in advance.

Jose Carlos.


Title: Re: Sending all table data from client to server
Post by: D.Tkalcec (RTC) on November 14, 2012, 08:26:57 PM
You can simply assign the "asDataSet" property of the TRtcMemDataSet component to any "asDataSet" parameter when preparing the remote function call. That will assign a copy of the original TRtcDataSet object, so it can be sent over to the Server. Here is a short example:
Code:
    RtcClientModule1.Prepare('send_table');
    RtcClientModule1.Param.asDataSet['mydata']:=RtcMemDataSet1.asDataSet;
    RtcClientModule1.Call(RtcResult1);

Best Regards,
Danijel Tkalcec


Title: Re: Sending all table data from client to server
Post by: Jose Carlos on November 15, 2012, 02:19:36 AM


  Your code works fine, the client now is sending the table, but I am having problem to get the table on the server.

  On the server size I added a RTCFunction and the name is "send_table" to get the table from the client.

  But I can't get the table on the server, it fires the RTCFunction.OnExecute but no data.

Code:
procedure TForm2.rtcGetTableFnExecute(Sender: TRtcConnection;
  Param: TRtcFunctionInfo; Result: TRtcValue);
begin
if Result.isType = rtc_DataSet then   <<<---  It is FALSE
  begin


      RtcMemDataSet1.asObject:=Result.asDataSet;
      Result.Extract;
      RtcMemDataSet1.Active:=True;


      while not RtcMemDataSet1.EOF do
        begin

          // write data on the server


          RtcMemDataSet1.Next;



        end;
end;
//


Can you help me on this?

Thanks

Jose Carlos.



Title: Re: Sending all table data from client to server
Post by: D.Tkalcec (RTC) on November 15, 2012, 08:42:28 AM
On the Server, you will get function parameters in "Param". "Result" is where you prepare the result of the function. If you have used my example and sent the DataSet in the "mydata" parameter, you can use this code to check if it arrived as expected:

if Param.checkType('mydata',rtc_DataSet) then

To access that data, you do NOT have to assign it to a RtcMemDataSet. You can access all the dataset data in code directly through the Param.asDataSet['mydata'] property:

var myDS:TRtcDataSet;
begin
  myDS:=Param.asDataSet['mydata'];
  myDS.First;
  while not myDS.EOF do
    begin
    // use myDS properties to access the record
    myDS.Next;
    end;
  end;

If you need the data inside a TRtcMemDataSet component, so you can use it with Data-aware components, you can assign the dataset from the "mydata" function parameter to the RtcMemDataSet1 component by using this code:

 RtcMemDataSet1.asObject:=Param.asDataSet['mydata'];
 Param.Extract('mydata');

For more information on working with remote functions, please check:
http://www.realthinclient.com/sf/index.php?topic=311.0

Best Regards,
Danijel Tkalcec


Title: Re: Sending all table data from client to server
Post by: Jose Carlos on November 16, 2012, 01:04:34 PM

 It works!
 
 Thank you.

  Jose Carlos.


Title: Re: Sending all table data from client to server
Post by: Jose Carlos on November 20, 2012, 02:49:00 PM
I am having an issue on my application server.

  I have an application that is in the middle of two applications and it receive and send data to clients, so I have two clients that send and receive to the same RtcHttpServer, on the same port ,

 I have two RtcFunctions one to send and one to receive data.

 Is this the right way to handle this ?
 
 I have a desktop application and an iOS application, now the iOS application is working receiving data from the server, but I am having connections issues with my desktop application.


The function to send data from desktop to the server it is getting a connection error ( #10061: Connection refused  ).  On the same server that it is fine to send data to the iOS application.

I am since yesterday trying to figure out what is happing, Is there something that I have data in and out to the same server ?

Thanks in advance.





Title: Re: Sending all table data from client to server
Post by: D.Tkalcec (RTC) on November 20, 2012, 03:11:42 PM
Provided you have set up your Desktop Client correctly, the "Connection refused" error usually means that the Server is too busy to accept new connections. This can happen if you are using a Server in single-threaded mode (MultiThreaded property on the TRtcHttpServer component is set to False) and you have functions on the Server which take a long time to complete. The connection problem would be resolved if you would set the MultiThreaded property to TRUE, but then you also need to make your code thread-safe (see THIS post (http://www.realthinclient.com/sf/index.php?topic=797.0)).

Best Regards,
Danijel Tkalcec


Title: Re: Sending all table data from client to server
Post by: Jose Carlos on November 23, 2012, 02:29:52 PM

 Hi,

 It was the port on the server blocking the communication, I fixed this and everything is working fine between my desktop application and the iOS application.

 Thank you very much.