Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Messaging child programs  (Read 8731 times)
Snorri B.
Posts: 103


« on: October 22, 2019, 12:19:44 pm »

Hi.
I have a program that can potentially fire up one or more children (RUN WITHOUT WAITING). In some cases I'd like to notify the children if the content in the parent program changes.

The only way apparently is to send a signal (interrupt/quit) to the children and there you have to check for the QUIT_FLAG / INT_FLAG etc. Then you have base.messageserver (does not work via GAS). I'm wandering if there is any other way to do this.

Thanks in advance,
-Snorri
Sebastien F.
Four Js
Posts: 509


« Reply #1 on: October 22, 2019, 12:43:45 pm »

Hi Snorri,

An option that I recommend to handle application events, is to have the parent program write to a database table with "events".

Then any (child) program can from time to time query that table (triggered by an ON IDLE)

The advantage of this solution is that you keep the trace of the events, and you can define as much info as you want to filter, mark as read/processed, etc...

Code
  1. CREATE TABLE app_events (
  2.   evt_num      BIGSERIAL NOT NULL PRIMARY KEY,
  3.   evt_source   VARCHAR(30) NOT NULL,
  4.   evt_ts       DATETIME YEAR TO FRACTION(3) NOT NULL,
  5.   evt_groupid  INTEGER,
  6.   evt_status   CHAR(1) NOT NULL,
  7.   ...


But maybe that's over-engineered for your case...

Seb
Reuben B.
Four Js
Posts: 1049


« Reply #2 on: October 22, 2019, 11:43:25 pm »

I'd second Seb, although perhaps use ON TIMER instead of ON IDLE

One other thing, have a study of how the Mobile world handles similar issue, Notifications http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_mobile_push_notifications.html and http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_mobile_push_notif_app_side.html.   Namely the 3 mobile front-calls http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_frontcalls_mobile.html to registerForRemoteNotifications, unregisterFromRemoteNotifications, and to getRemoteNotifications, and the special predefined action for mobile of ON ACTION notificationpushed.  I'd suggest constructing your solution so that

Code
  1. ON TIMER
  2.   IF notification_pushed() THEN ...

could one day be replaced by

Code
  1. ON ACTION notificationpushed
  2.  

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Leo S.
Four Js
Posts: 126


« Reply #3 on: October 23, 2019, 12:06:39 am »

Hi Snorri, if base.MessageServer would work via GAS the same way as in direct mode, would that solve your problem ?
Otherwise it would be nice if you could give more details about your particular use case.
Regards, Leo
Snorri B.
Posts: 103


« Reply #4 on: October 23, 2019, 01:28:11 am »

Hi guys and thanks for the input.
Maybe I should explain in more detail what I am trying to achieve. Consider a simple application, Customers, Orders and Invoices.

The main program has the customer detail (query/input/display, next, prev etc.) The user selects a customer and fires the Orders action, The Orders program is RUN WITHOUT WAITING. It will display the orders for that particular customer.
Then the user selects a different customer. Then I would like to notify the Orders program to get the orders for that customer. Same goes for Invoices, maybe both are open at the same time.

So In my case, ON TIMER / IDLE would not do the trick as it would perhaps delay the refresh for too long and confuse the user. Notifications like in the mobile environment would work, and probably base.MessageServer. The events would be passed on through the database like Seb suggested.
Best regards,
-Snorri
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines