Completed
Pull Request — master (#6)
by Timo
06:41
created

InternalSessionMonitor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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\SessionMonitor;
14
use Tidal\WampWatch\Adapter\Thruway\ClientSession as Adapter;
15
16
/**
17
 * Class InternalClient
18
 */
19
class InternalSessionMonitor extends Client
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
20
{
21
22
    /**
23
     * Constructor
24
     */
25
    public function __construct()
26
    {
27
        parent::__construct("realm1");
28
    }
29
30
    /**
31
     * @param \Thruway\ClientSession                $session
32
     * @param \Thruway\Transport\TransportInterface $transport
33
     */
34
    public function onSessionStart($session, $transport)
35
    {
36
37
38
        $sessionMonitor = new SessionMonitor(new Adapter($session));
39
40
41
        $sessionMonitor->on('list', function ($l) {
42
            echo "\nLIST: \n";
43
            print_r($l);
44
        });
45
46
        $sessionMonitor->on('join', function ($l) {
47
            echo "\nJOIN: \n";
48
            print_r($l);
49
        });
50
51
        $sessionMonitor->on('leave', function ($l) {
52
            echo "\nLEAVE: \n";
53
            print_r($l);
54
        });
55
56
        $sessionMonitor->on('error', function ($l) {
57
            echo "\nERROR: \n";
58
            print_r($l);
59
        });
60
61
        $sessionMonitor->start();
62
63
        echo "\n******** SESSION MONITOR STARTED ********\n";
64
65
    }
66
67
68
    public function onMessage(Thruway\Transport\TransportInterface $transport, Thruway\Message\Message $msg)
69
    {
70
        echo "\n";
71
        //print_r($msg);
72
        parent::onMessage($transport, $msg);
73
    }
74
75
}