/* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ $app->get('/', function () use($app) { return file_get_contents("welcome.php"); }); $app->get('/nextCommand', function () use($app) { $redis = new Predis\Client(); return $redis->rpop('spheroCommands'); }); /** * @api {get} /roll/key/:key/ball/:ballId/angle/:angle/speed/:speed * @apiName RollBall * @apiGroup SpheroCommands * * @apiParam {String} client api key * @apiParam {Number} ball id number 0 - first ball, 1 - second ball, 2 - both balls * @apiParam {Number} angle from opposite backlight to travel 0-359 * @apiParam {Number} speed 0-1000 increments of 10 on how fast ball should travel * * @apiSuccess {String} Success */ $app->get('/roll/key/{key}/ball/{ball}/angle/{angle}/speed/{speed}', function ($key, $ball, $angle, $speed) { try {
} $config = \Symfony\Component\Yaml\Yaml::parse('config/podisum.yml'); if (class_exists('MongoClient')) { $mongo = new \MongoClient($config['mongo']); } else { $mongo = new \Mongo($config['mongo']); } $podisum = new Podisum($mongo, $config); $podisum->ensureIndexes(); $redis = new Predis\Client($config['redis']); $len = $redis->llen($config['redis_key']); echo "Found {$len} entries waiting on list...\n"; $processed = 0; $sleep = $podisum->getConfig('default_sleep', 1); while (1) { $value = $redis->rpop($config['redis_key']); if (null === $value) { echo "no more data, sleeping...\n"; sleep($sleep); continue; } $data = json_decode($value, true); if (!$data) { echo "Invalid json string " . $value; continue; } $process = false; $tags = isset($data['tags']) ? $data['tags'] : $data['@tags']; foreach ($tags as $tag) { $cfgs = $podisum->getConfigForTag($tag); foreach ($cfgs as $cfg) {