137
Views
5
Comments
Solved
Timer problem.
Question

Hi,

I already asked something similar or quite the same in another post.

I thought I had the issue fixed but in the end I did not and I already marked the other post as Marked.

I dont know if I can continue to ask there so I created another one here.

Sorry if I am wrong.

- Core module I have this Server Action inside: 

- UI Module I have a timer inside processes:

I thought I understood what I had to do and thought it was working. But  in the end I was wrong.

I have no idea what should i use there!!

Thank you in advance.

Kind regards,

Pedro Boffa


2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Yes exactly,

timers are there to do things automatically, on the server side, regardless of a user currently using any of your front end or not.  Architecture of real applications is much more complex than just a core and ui module, but yes, if you only have those 2, I would expect to see them in the core rather than the ui.

Your local variable with money, is exactly that : a local variable, meaning available only in the browser/client where your user is currently playing.

Making use of SetInterval() is not an Outsystems feature, but a Javascript feature, so you can google that to know al the details and options, but no, it's not limited to just one Interval per screen or anything like that.

Dorine

2020-09-01 10-42-42
Stefano Valente

What are you trying to do here?

Timers are used for bulkoperations, but you only save 1 record in 3 entities.

Your inputparameters are empty and you cannot set them when you call a timer.


I would think you need bpt for this use case. a timer would look like this:


2021-09-06 15-09-53
Dorine Boudry
 
MVP

Hi Pedro,

I think you are confusing 2 things :

an Outsystems timer, which is a mechanism to launch a piece of logic at scheduled times on the server side without the need for user involvement or UI input

a Javascript timing event, which is a mechanism for triggering a piece of logic on client side inside the browser during an end user interaction (i.e. while a user has a certain screen open).  

I think you want to update information about the current state of your game, from the UI to the server, so you'll need the second, not the first.  So I guess you'll want something like a SetInterval() to run a screen client action on your screen, which in turns calls your SaveEveryMinute server action, passing your user's current player, chicken and rat.

Dorine

2022-01-25 15-06-08
Pedro Boffa

Hi,

Thank you very much for all the answers.

I thought that timers were ment to do things for me automatically.

Like sending and email to me or to the user time to time or saving some data inside database time to time...etc..etc..

I am already using SetInterval(). When the player buys a chicken for example, that chicken using the SetInterval() will give me 2 gold per second. If I use it again for another thing it will work too?

Out systems has diferent threads active automatically ?

So If I have like in my case a local variable Long Integer called Money,

and all the money I have now is there, but every 5 min or 1min I would like to get the number that is inside that variable and save it in a specific atribute inside database.

So SetInterval() would be my best shoot and not timers?

So as the local variable is inside client side I need to use SetInterval() and If I want something scheduled from the server side I would use timers, correct?

So timers are meant  to be created inside the Core and not inside Client?

Kind regards,

Pedro Boffa


  

2021-09-06 15-09-53
Dorine Boudry
 
MVP
Solution

Yes exactly,

timers are there to do things automatically, on the server side, regardless of a user currently using any of your front end or not.  Architecture of real applications is much more complex than just a core and ui module, but yes, if you only have those 2, I would expect to see them in the core rather than the ui.

Your local variable with money, is exactly that : a local variable, meaning available only in the browser/client where your user is currently playing.

Making use of SetInterval() is not an Outsystems feature, but a Javascript feature, so you can google that to know al the details and options, but no, it's not limited to just one Interval per screen or anything like that.

Dorine

2022-01-25 15-06-08
Pedro Boffa

Amazing.

I tried here and its working now using the SetInterval().

I used a switch widget. When its on the Setinterval is triggered and starts saving every 1 min.

When the switch is off it stops the auto save.

Thank you very much for the enlightening explanation.

Great sunday for you all.

Kind regards,

Pedro Boffa

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.