<commit_before><?php

/**
 * Walrus Framework
 * File maintained by: <NAME> (E-Wok)
 * Created: 00:09 08/02/14
 */

namespace engine\api;

use Walrus\core\WalrusAPI;

/**
 * Class PollingController
 * @package engine\api
 */
class PollingController extends WalrusAPI
{
    public function run()
    {
        return array('hello'=> "lol");
    }
}
<commit_msg>Polling controller: start a simple polling loop<commit_after><?php

/**
 * Walrus Framework
 * File maintained by: <NAME> (E-Wok)
 * Created: 00:09 08/02/14
 */

namespace engine\api;

use Walrus\core\objects\SessionHandler;
use Walrus\core\WalrusAPI;

/**
 * Class PollingController
 * @package engine\api
 */
class PollingController extends WalrusAPI
{
    public function run()
    {
        $session_handler = new SessionHandler();
        session_set_save_handler($session_handler);
        session_start();

        $start = time();
        $longPollingCycleTime = 5;
        $realTimeLatency = 1;

        session_id();
        session_write_close();

        $response = array();

        while (time() < $start + $longPollingCycleTime) {


            if (!empty($msgs)) {
                exit();
            }
            sleep($realTimeLatency);
        }

        $response['msgs'] = array();
        return $response;
    }
}

{'fraction_non_alphanumeric': 0.1241782322863404, 'fraction_numerical': 0.016070124178232285, 'mean_word_length': 2.106575963718821, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3929762', 'n_tokens_mistral': 455, 'n_tokens_neox': 406, 'n_words': 90}