Search code examples
phpnode.jssocketsreal-time

How to implement real time application pure


I am actually developing application for bank cash management.. It must be real-time... Once there is a change in db it must be sent to the client... I don't want to use long polling or ajax etc... (Because It puts load on the server by repeating requests)...

Cant use nodejs or other server related technology... (Not installed in server)... Question is that I want to develop server pure in php... Can anyone post code and give the details about it... Searched internet a lot but nothing there... Suggestions will be appreciated

[Edit]

I am putting my angularjs code for long polling here:

function dataCtrl($scope, $timeout, Data) {
                $scope.data = [];

                (function tick() {
                    $scope.data = Data.query(function(){
                        $timeout(tick, 1000);
                    });
                })();
            };

and I call tick function in the following code

$http.get('url').success(function(data, status, headers, config) {
                  data.response = data;
                  $('.serverStatus').text(data.response.message);
                  data.calls++;
                  $timeout(poller, 1000);
                });
              };

Solution

  • You must use sockets in your application... You can find Php socket library named Rachet over here http://socketo.me/

    There must be socket connection between users. So socket will listen until the data comes