<commit_before><?php

require_once realpath(__DIR__.'/..').'/bootstrap.php';

/*
 * This file is part of the Tidal/WampWatch package.
 * (c) 2016 <NAME> <timomichna/yahoo.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */


use Psr\Log\NullLogger;
use Thruway\ClientSession;
use Thruway\Connection;
use Thruway\Logging\Logger;
use Tidal\WampWatch\Adapter\Thruway\ClientSession as Adapter;
use Tidal\WampWatch\SessionMonitor;
use Tidal\WampWatch\Adapter\React\PromiseFactory;

Logger::set(new NullLogger());

$connection = new Connection(
    [
        'realm' => 'realm1',
        'url'   => 'ws://127.0.0.1:8080/ws',
    ]
);

$connection->on('open', function (ClientSession $session) use ($connection, &$timer) {
    $sessionMonitor = new SessionMonitor(new Adapter($session, new PromiseFactory()));

    echo PHP_EOL . "******** SESSION MONITOR STARTED ********" . PHP_EOL;
    $sessionMonitor->on('start', function ($l) {
        echo PHP_EOL . "START: " . PHP_EOL;
        print_r($l);
    });

    $sessionMonitor->on('list', function ($l) {
        echo PHP_EOL . "LIST: " . PHP_EOL;
        print_r($l);
    });

    $sessionMonitor->on('join', function ($sessionData) {
        echo PHP_EOL . "JOIN: {$sessionData->session}" . PHP_EOL;
    });

    $sessionMonitor->on('leave', function ($sessionId) {
        echo PHP_EOL . "LEAVE: $sessionId" . PHP_EOL;
    });
<commit_msg>add session IDs to debud output<commit_after><?php

require_once realpath(__DIR__.'/..').'/bootstrap.php';

/*
 * This file is part of the Tidal/WampWatch package.
 * (c) 2016 <NAME> <timomichna/yahoo.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */


use Psr\Log\NullLogger;
use Thruway\ClientSession;
use Thruway\Connection;
use Thruway\Logging\Logger;
use Tidal\WampWatch\Adapter\Thruway\ClientSession as Adapter;
use Tidal\WampWatch\SessionMonitor;
use Tidal\WampWatch\Adapter\React\PromiseFactory;

Logger::set(new NullLogger());

$connection = new Connection(
    [
        'realm' => 'realm1',
        'url'   => 'ws://127.0.0.1:8080/ws',
    ]
);

$connection->on('open', function (ClientSession $session) use ($connection, &$timer) {
    $sessionMonitor = SessionMonitor::create(new Adapter($session, new PromiseFactory()));

    echo PHP_EOL . "******** SESSION MONITOR STARTED ********" . PHP_EOL;
    $sessionMonitor->on('start', function ($l) {
        echo PHP_EOL . "START: " . PHP_EOL;
        print_r($l);
    });

    $sessionMonitor->on('list', function ($l) {
        echo PHP_EOL . "LIST: " . PHP_EOL;
        print_r($l);
    });

    $sessionMonitor->on('join', function ($sessionData) use ($sessionMonitor) {
        echo PHP_EOL . "JOIN: {$sessionData->session}" . PHP_EOL;

        $sessionMonitor->getSessionIds()->then(function (array $sessions) {

            echo "SESSIONS : " . count($sessions) . PHP_EOL;

        });
    });

    $sessionMonitor->on('leave', function ($sessionId) use ($sessionMonitor) {
        echo PHP_EOL . "LEAVE: $sessionId" . PHP_EOL;
        $sessionMonitor->getSessionIds()->then(function (array $sessions) {

            echo "SESSIONS : " . count($sessions) . PHP_EOL;

        });
    });

{'fraction_non_alphanumeric': 0.16299426501660128, 'fraction_numerical': 0.009055236945366738, 'mean_word_length': 3.337696335078534, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6328696', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1079, 'n_words': 242}