samedi 22 février 2020

How to implement EventSource on Codeignigter app?

I'm trying to send my end user simple updates on the progress of a data conversion in my app. I researched for a while and found EventSource to be the best solution (lightweight and simple). The problem is, I can't seem to get it to listen for events on the correct model/view/controller in codeigniter.

I have a query submission being sent from a form_open_multipart in an index.php in Views. I use routes.php to route the data to the correct controller (c_controller.php), specifically to a method called getProduct(). This method validates and then passes the query to the main method of a model (cfa_model.php) called getProductByDate(). GetProductsByDate() returns the data after being processed and getProduct (in the controller) loads a new "job finished" view with the resulting data.

I want the index.php file (the first one I mentioned) to get the updates of the processing in getProductsByDate(). I tried to set up EventSource listening in index.php to listen to cfa_model.php, but it didn't work. I was able to get it to listen to c_controller.php, but this will not suffice. I need to get consistent updates from the process itself, and the process is only in cfa_model.php.

Is this just a problem with my routes? Could it be my headers? Can I set up cfa_model.php to update another controller and hook a listener to that?




Aucun commentaire:

Enregistrer un commentaire