Call function in an NG Client instance from server

Forum to discuss the new web client version of Servoy.

Call function in an NG Client instance from server

Postby roddy » Wed Jul 13, 2022 8:12 am

I am trying to find a way of calling a function in an instance of an NG Client; primarily, this is to process a callback from another web page opened from that client.

The JSClient can be used for Headless Clients to use queueMethod() but I cannot find a way of getting a JSClient instance from the GetClientID() of an NG Client. The closest I can find is plugins.headlessclient.getOrCreateClient(), which is again only for headless clients.

The upshot being that I am seeking a way to call a function in a running instance of NG Client from a call received on the server; unless it is possible for an instance of NG Client to get a callback directly.
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am

Re: Call function in an NG Client instance from server

Postby mboegem » Wed Jul 13, 2022 8:52 am

To get the full picture:
What is it that this callback action should do?
Write data, UI update, both, anything else?
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1742
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Call function in an NG Client instance from server

Postby jcompagner » Wed Jul 13, 2022 9:41 am

also how is this first call triggered?
because you seem to talk about another kind of webpage opened by the ngclient
so that is just in another tab?
and that wants to call then the server based on some url?

Then inside that url you need to give some uuid that you know what client that is..
And maybe that url can just be a rest url to server that hits a rest api (headless client)
that headless client uses then the broadcaster (clientmanager plugin) to broadcast a message over a specific channel with that uuid
the ngclient listens on that channel knows its uuid and knows then this message is mine (or that channel name is the uuid and you have many channels)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Call function in an NG Client instance from server

Postby roddy » Thu Jul 14, 2022 12:03 am

Thanks for the responses. To provide more detail, we have to provide a callback URL to a payment service, so if we get a specific notification of a status from an external payment API call to this service, it requires the application to open up a separate web page supplied in the response for more details to be entered. This separate web page is run by a bank and requires additional data to be entered by the user before the transaction can continue.

This entails that the Servoy app has to await the response of the callback from this web page in the NG Client and I've been trying to work out a way to implement this.
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am

Re: Call function in an NG Client instance from server

Postby jcompagner » Thu Jul 14, 2022 9:59 am

is that redirect done in the same browser tab where the ngclient is loaded?

because potentially you could use then a deeplink callback url that just calls a function when it is done, then you are hitting the same NGClient instance.
If that payment can take longer then 60 seconds it could be that you need to increase the window timeout, see APP_NG_PROPERTY.WINDOW_TIMEOUT
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Call function in an NG Client instance from server

Postby roddy » Fri Jul 15, 2022 12:11 am

It would be opened in a separate browser tab; it is an interesting idea to open in the same tab then deep link back but I think it would be tricky as we have no control over what is in the called web page. If one of them said something like, "You can now close this window", it could really throw a spanner in the works.
roddy
 
Posts: 100
Joined: Mon Oct 26, 2020 12:32 am

Re: Call function in an NG Client instance from server

Postby jcompagner » Fri Jul 15, 2022 9:16 am

if you open this in a separate window then you just need to follow the first comment i did in this thread.

So the callback the 3rd party website does is a rest api call to our rest service (headless client) and that headless client just relays that message to our clientmanager.getBroadcaster() on a channel which will be picked up by the ngclient that did the initial call
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 9 guests