RTC Forums
September 17, 2019, 03:25:01 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: calling server side function from a server function request execution  (Read 393 times)
bebeantics
RTC License+
****
Posts: 25


« 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
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1796


« Reply #1 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?
Logged
bebeantics
RTC License+
****
Posts: 25


« Reply #2 on: May 19, 2019, 03:13:19 PM »

the server inside func1 execution
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1796


« Reply #3 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.
Logged
bebeantics
RTC License+
****
Posts: 25


« Reply #4 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(Huh, params, res);  Huh 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.

Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1796


« Reply #5 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.
Logged
bebeantics
RTC License+
****
Posts: 25


« Reply #6 on: May 19, 2019, 08:30:21 PM »

Thank you
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 16 queries.