Passed
Branch master (03ab13)
by Timo
03:14
created

InternalSessionMonitor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 3
c 2
b 1
f 1
lcom 0
cbo 3
dl 0
loc 51
rs 10
1
<?php
2
3
4
/*
5
 * This file is part of the Tidal/WampWatch package.
6
 * (c) 2016 Timo Michna <timomichna/yahoo.de>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
use Thruway\Peer\Client;
13
use Tidal\WampWatch\Adapter\Thruway\ClientSession as Adapter;
14
use Tidal\WampWatch\SessionMonitor;
15
16
/**
17
 * Class InternalClient.
18
 */
19
class InternalSessionMonitor extends Client
20
{
21
    /**
22
     * Constructor.
23
     */
24
    public function __construct()
25
    {
26
        parent::__construct('realm1');
27
    }
28
29
    /**
30
     * @param \Thruway\ClientSession                $session
31
     * @param \Thruway\Transport\TransportInterface $transport
32
     */
33
    public function onSessionStart($session, $transport)
34
    {
35
        $sessionMonitor = new SessionMonitor(new Adapter($session));
36
37
38
        $sessionMonitor->on('list', function ($l) {
39
            echo "\nLIST: \n";
40
            print_r($l);
41
        });
42
43
        $sessionMonitor->on('join', function ($l) {
44
            echo "\nJOIN: \n";
45
            print_r($l);
46
        });
47
48
        $sessionMonitor->on('leave', function ($l) {
49
            echo "\nLEAVE: \n";
50
            print_r($l);
51
        });
52
53
        $sessionMonitor->on('error', function ($l) {
54
            echo "\nERROR: \n";
55
            print_r($l);
56
        });
57
58
        $sessionMonitor->start();
59
60
        echo "\n******** SESSION MONITOR STARTED ********\n";
61
    }
62
63
    public function onMessage(Thruway\Transport\TransportInterface $transport, Thruway\Message\Message $msg)
64
    {
65
        echo "\n";
66
        //print_r($msg);
67
        parent::onMessage($transport, $msg);
68
    }
69
}
70