reactApp::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
require __DIR__.'/../vendor/autoload.php';
3
4
use Ratchet\MessageComponentInterface;
0 ignored issues
show
Bug introduced by
The type Ratchet\MessageComponentInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use Ratchet\ConnectionInterface;
0 ignored issues
show
Bug introduced by
The type Ratchet\ConnectionInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Ratchet\Server\IoServer;
0 ignored issues
show
Bug introduced by
The type Ratchet\Server\IoServer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Ratchet\Http\HttpServer;
0 ignored issues
show
Bug introduced by
The type Ratchet\Http\HttpServer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Ratchet\WebSocket\WsServer;
0 ignored issues
show
Bug introduced by
The type Ratchet\WebSocket\WsServer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use darknet\core;
10
11
/**
12
 * Description of react
13
 *
14
 * @author ghost
15
 */
16
class reactApp implements MessageComponentInterface {
17
    protected $client, $objDetc;
18
    
19
    public function __construct() {
20
        $this->client = new \SplObjectStorage();
21
        $this->yolo();
22
    }
23
24
    public function onClose(ConnectionInterface $conn) {
25
        $this->client->detach($conn);
26
        echo "Connection closed for CID:-> {$conn->resourceId}\n";
27
    }
28
29
    public function onError(ConnectionInterface $conn, \Exception $e) {
30
        echo "An Error has occurred: {$e->getMessage()}\n";
31
        $conn->close();
32
    }
33
34
    public function onMessage(ConnectionInterface $from, $msg) {
35
        foreach ($this->client as $client) {
36
            if($from !== $client) {
37
                if(!is_null($msg)){
38
                    $this->objDetc->remotePR($client,$msg);
39
                }
40
                else {
41
                    $data = ['id' => $from->resourceId, 'msg' => $msg];
42
                    $client->send(json_encode($data));
43
                }
44
            }
45
        }
46
    }
47
48
    public function onOpen(ConnectionInterface $conn) {
49
        $this->client->attach($conn);
50
        echo "New connection for CID:-> ({$conn->resourceId})\n";
51
    }
52
    
53
    protected function yolo() {
54
        return $this->objDetc = new core(core::MOBILE_NET_V2_VOC,core::DATA_VOC);
55
    }
56
57
}
58
59
$server = IoServer::factory(
60
	new HttpServer(
61
		new WsServer(
62
			new reactApp()
63
		)
64
	),8080,'0.0.0.0');
65
$server->run();
66