What kind of server side implementation do you use? On linux based servers you could use cron jobs to run a php script. With nodejs we will introduce our own cron/scheduler.
Thank you @patrick for your quick response. My hosting uses Linux servers. I found the functionality for creating cron tasks. And this will really help me implement some of my server logic tasks. However, the functionality allows you to work only with a timeframe of at least a minute. This makes it impossible to implement quite a large part of the logic that I need.
Example: I need to implement a quiz in which each question is given exactly 12 seconds. The timer necessarily must run on the server side, and if the user does not have time to respond, the corresponding entry is made in the database.
I do not see the possibility to implement this via cron tasks on my hosting, because the minimum step of time that the hosting allows me to work with is equal to a minute.
With your example a cronjob indeed will not work, a cronjob is used to setup recurring events on the server to do some action at a specific interval. In your case you want to only have some sort of timeout, on the client-side this is easy to implement with the flows, but for the server-side there is no solution for this.
I thought about it, and I got an idea. When my user receives a question from the quiz, this question is set to the timestamp of the current server time. If I create a server action with an infinite While loop that checks the condition for comparing the current server time with the time field in the question table, and all questions that have a field that differs by 12 seconds or more will change their status and leave the selection. I will run this script in the background on my hosting so that it works constantly. How rational can this be?
@Mr.Rubi can you on the server side just have a field in the DB that is timeQuestionSent and save the time in the DB when you send the question or it is requsted from the client and then on save check the server local time and if it has been greater than 12 seconds then mark the question as unanswered or whatever value you want it to be. This stops the user from faking the data by relying upon the untrusted client input. However for the user side you can then just control all the flow with the frontend App Connect (i.e setting the timers and the timeout and the flow of the questions etc)?
Why not trigger an App Connect scheduler for 12 seconds within the success event of the server action when it returns the question.The scheduler can then trigger whatever you need it to do when 12 seconds counts down
@datguru Yes, this is the decision I had originally planned. But it does not fully satisfy what needs to be done according to the scenario. I have a more complex scenario (not related to the quiz) in which there are options where certain events should occur on the server side after a certain time has elapsed from the checkpoint, regardless of whether the user is currently connected or not. This requires high accuracy, which can not be provided by the cronjob of the task in 1-minute increments.
@Hyperbytes I need a server-side solution. So that the decision does not depend on the user in any way:
the User did not have any possibility to manipulate the data (partially solved by the implementation described above).
the event Scenario was implemented regardless of whether the user was online or offline.
Do not make an infinite while loop on the server, it would make your server unresponsive. Do you use PHP? Then I could give you a solution to use https://www.php.net/manual/en/function.sleep.php. In the node server we also have a wait/delay step like in the client-side flows.
I think @datguru solution is the best and would not have any performance issue. You could run an extra cronjob that checks the database for abandoned users and take action. Cronjob could run every minute, but I would not suggest to run it that often.
Could just have a table with job attributes and match conditions against them to run based on their output. Just execute the query to this table as you would any other query, then add your Conditions thereafter. You can manage this table within an administration area for example. Allowing you to make changes as required.
However. Would be nice to be able to actually set the Schedule Action Settings themselves dynamically, but using a little logic its not too difficult to achieve most requirements.
Can store your last run/next run times in the table with an insert once the Condition is met with regards to pending items etc. Or have a separate log table to hold this data? Then query that in your administration area also.
You have if, else, wait, exec, while, etc. Just explore and have fun! Who knows what you’ll come up with.