RTC Forums

Subscription => Support => Topic started by: bebeantics on May 19, 2019, 02:18:26 PM



Title: calling server side function from a server function request execution
Post by: bebeantics on May 19, 2019, 02:18:26 PM
Hello

I have the following example that I do not know how to implement it, maybe I have not looked for enough, but I would like to ask you to help me solve it:

The server has two functions func1 and func2, each function with one or more parameters. the client calls and the server executes the fun1 function.
During function exec1, it must be called, together with its parameters, func2. This is the part to which I would like to help.

Thank you


Title: Re: calling server side function from a server function request execution
Post by: D.Tkalcec (RTC) on May 19, 2019, 02:58:37 PM
Who has to call "func2"? The Server from its "exec1" event (while executing "func1") or the Client?


Title: Re: calling server side function from a server function request execution
Post by: bebeantics on May 19, 2019, 03:13:19 PM
the server inside func1 execution


Title: Re: calling server side function from a server function request execution
Post by: D.Tkalcec (RTC) on May 19, 2019, 03:25:51 PM
If "func2" is called directly by the Server, I'd recommend writing "func2" as a "normal" Delphi function in your Server Project. Then, you can call "func2" directly from anywhere in your Delphi Application, like ... for example ... the "exec1" event of "func1". And if the code of your "func2" function also has to be accessible remotely from Clients (independent of "func1"), then write a remote function that calls that local function.


Title: Re: calling server side function from a server function request execution
Post by: bebeantics on May 19, 2019, 03:35:29 PM
somthing like:

server

func2, call funcexec function as a local function

func1, inside execution call the same funcexec

?

i try now this but i stuck (is not tested yet) (this is inside func1 body) (is not like you sugested)

...
              params:=trtcfunctioninfo.Create;
              params.asString['tel']:='xxx';
              params.asString['txt']:='yyy';
              try
                sendsmsNotif.Call_Execute(???, params, res);  ??? here i stuck
              except
              on e:exception do
                logfile('ERR', 'ERR', 'Send SMS inside new HTTP order, with execution error'+e.Message);
              end;
              params.Free;
...


where sendsmsNotif is func2 with remotecall possibilitie as stand alone as well.



Title: Re: calling server side function from a server function request execution
Post by: D.Tkalcec (RTC) on May 19, 2019, 03:43:04 PM
No, not like that.

I meant that "funcexec2" should be a normal local Delphi function, like this ...

function funcexec2(tel:string;txt:string):boolean;
  begin

  // do somehing with "tel" and "txt" parameter and return a result ...
  end;

And since "funcexec2" is a normal local Delphi function, you would call it like this from inside func1 body ...

funcexec2('xxx','yyy');

And if "funcexec2" should also be made accessible remotely from Clients, then you can write "func2" as a remote function (just like "func1") and call "funcexec2" from its execute event.


Title: Re: calling server side function from a server function request execution
Post by: bebeantics on May 19, 2019, 08:30:21 PM
Thank you