I have a PHP application in the CodeIgniter framework, running on an Apache server with a MySQL database. There's a lot of database communication, all done through an abstraction layer. It's a game application and, when the user opens the page, a list of open games with some additional info is fetched from MySQL using PHP and shown on the page. Now, I need to set it up so the list updates live. I need a websockets server for this because the lag is too big when I use Ajax, and I've decided to go with Node.js + sockets.io for the implementation. I don't really need to contact the database every time, I can update the list based on user actions on the client.
This is where I'm stuck - after loading the list with PHP the first time, how do I send it over to Node.js? I found a solution that involves sending a HTTP request for this purpose, but this seems redundant since, at this point, I already have all the data displayed on the client.
Here's some sample data, in a PHP array before being displayed on the page:
array(2) { [0]=> object(stdClass)#19 (6) { ["id"]=> string(1) "1" ["admin_id"]=> string(1) "2" ["start_date"]=> string(19) "2013-11-18 07:19:46" ["status"]=> string(1) "1" ["username"]=> string(15) "Marko Marković" ["option"]=> string(5) "start" } [1]=> object(stdClass)#20 (6) { ["id"]=> string(1) "2" ["admin_id"]=> string(1) "3" ["start_date"]=> string(19) "2013-11-18 07:20:32" ["status"]=> string(1) "1" ["username"]=> string(13) "Dzoni Noksvil" ["option"]=> string(5) "start" } }
Is there a way I can package this up on the client and then just have Node pick the data up from the client, so there would be no need to send the data from PHP directly to Node?