I have an app that I need to make it send http requests and receive response , but I want to make it send all requests that it has at once, is there any app in the NextCloud that behaves is similar way? or does the NextCloud server support such a capabilities?
You can setup a cron job, that will do the request at the next tick.
If you need something more ‘live’ you should have a look to the Circles apps: I found a (experimental) way to create an async process by sending a local request to the cloud:
- Current webpage (process A) send a request to the local cloud
- process B is opened by the request
- process B is closing the socket, setting process A free
- process A is now free and can stop
- process B is still alive and do what ever you need to do.
I don’t think that “cron job” is suitable since the requests depend on events so I cant predict when to send and when not to, but the code that you have shared sound reasonable enough.
but how can I use it correctly? assume I have in the php script a function called PostRequest(), is this syntax is correct?
I saw that it was used in a similar way at the TestController.php code, the line was like this:
I presume I should do the same correct?
There string you’re sending as a parameter to asyncAndLeaveClientOutOfThis() is totally useless.
The asyncTestRun method is called by a PUT request to /admin/testAsync
- The PUT request is made by the process A
- it open a new process B that call the asyncAndLeaveClientOutOfThis
- from now on, everything in the asyncTestRun() after this line is run in the process B, and process A died.
You can see that there is a while() that run for 120 seconds that keep process B alive while A is gone.