Page 1 of 1

does creating headless-client start the onSolutionOpen?

PostPosted: Fri Oct 26, 2012 10:38 am
by Harjo
Hi,

when you create a headless client with code like this:

Code: Select all
      // Creates a headless client that will open the given solution.
      var headlessClient = plugins.headlessclient.createClient("someSolution", "user", "pass", null);
      if (headlessClient != null && headlessClient.isValid()) {
         var x = new Object();
         x.name = 'remote1';
         x.number = 10;
         headlessClient.queueMethod(null, "remoteMethod", [x], callback);
      }

Does the solution than also fires the onSolutionOpen method?

I'm asking this, because I have one solution, that is working as a batchprocessor (= headlessclient) and I want to use it for offloading work to the server. (= also headless client)
The reason that it is one solution, is that I need 90% of the methods in both situations.

But in case of creating the headless client in code, I don't want the onSolutionOpen to fire, because there are cronjobs scheduled, that I don't want.
I can't also check in the onSolutionOpen if it is batchprocessor or headless-client, because there is only one Constant: APPLICATION_TYPES.HEADLESS_CLIENT

Anyone have an idea?

Re: does creating headless-client start the onSolutionOpen?

PostPosted: Fri Oct 26, 2012 11:08 am
by Hans Nieuwenhuis
Maybe You could use different startup parameters.

For instance set Type= batch in servoy admin page for batch processor
and set Type=hlClient when starting it as a headlessclient in the call to start the headless client.

Regards,

Re: does creating headless-client start the onSolutionOpen?

PostPosted: Wed Nov 07, 2012 12:53 am
by jcompagner
headless clients are just clients, they should act as a normal client, so yes onsolutionload should be called.

Why not have an empty solution wrapper around that main solution? So that that solution is just a module
And in a headless client you just load that solutionname_hc solution instead of the solutionname itself?

Re: does creating headless-client start the onSolutionOpen?

PostPosted: Wed Nov 07, 2012 7:18 pm
by Harjo
Thanks Johan, that's a great idea!

PS. if I do this, the onSolutionOpen of the main-solution (in this case the module) is not fired right?

Re: does creating headless-client start the onSolutionOpen?

PostPosted: Thu Nov 08, 2012 11:05 am
by mboegem
Harjo wrote:PS. if I do this, the onSolutionOpen of the main-solution (in this case the module) is not fired right?


correct!