CAF Receiver, shutdown handling to http requests

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



CAF Receiver, shutdown handling to http requests



Some background reading at first :) what is shutdown handling



I'm doing a custom receiver with CAF SDK.



With the similar shutdown handling, I try to dispatch some http requests within the callback like:


receiver.addEventListener(
cast.framework.system.EventType.SHUTDOWN,
e =>
// some http requests
HttpHandler.post(url, somePayload);
HttpHandler.post(anotherUrl, someOtherPayload);
....... (more requests to go)
);



However, I can't guarantee those requests are reaching the destination since the receiver application is about to terminate anytime(Likely less than 1 sec).Those requests were also proved not reaching the destination in fact.



As far as I know, there is no way to postpone the shutdown of the receiver application with CAF SDK itself.



Is there a workaround about it? Is there a way we can postpone shutdown with the help of CAF SDK?




1 Answer
1



The answer seems quite simple: turn all http requests to synchronous.



Drawbacks are quite obvious as well, synchronous requests will block the thread. When one request is hung in middle of somewhere due to unknown reasons, the script will be blocked forever unless force shutdown.



Still looking for better way to improve it.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard