javascript - Pusher client subscribed and running from command line -
i have integrated script on php file. reading pusher channel , several actions when there new event on listed channel.
if run on browser:
http:/localhost/pusher.php
and let open pusher connection keeps reading, if close or run on command line:
php pusher.php
the script opens , ends in less 1 second closing connection , not reading future entries.
question: simpler way run (pusher) js , keep opened , reading under command line?
<?php require 'vendor/autoload.php'; ?> <html> <script src="//js.pusher.com/2.2/pusher.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <script type="text/javascript" language="javascript"> var pusher = new pusher('key'); var channel = pusher.subscribe('betfair'); channel.bind('bets', function(data) { var = data.market_id; var b = data.selection; var c = data.stake; var d = data.odd; var e = data.bet_type; record(a, b, c, d, e); }); function record(a,b,c,d,e) { console.log(a); jquery.ajax({ type: "post", url: 'time2.php', data: {a, b , c , d, e}, success:function(record) { console.log(data); } }); } </script> </html>
javascript strictly client side language (exceptions being things rhino, nodejs, etc), things trying depend on environment provided web browser, or more virtual machine attached browser interprets js. may have heard of v8 example used chrome.
when run script via command line renders js. nothing parsing it.
you need @ php http client curl (or maybe @ guzzle these days).
as long ruinning server side process... these tasks typically run people call daemon. maybe read started on topic: run php script daemon process knowing google should find plenty on topic.
Comments
Post a Comment