anonymous()
last analyzed

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 2
1
<?php
2
3
require '../vendor/autoload.php';
4
5
if (!extension_loaded('swoole')) {
6
    dl('swoole.so');
7
}
8
9
use darknet\core;
10
11
$dn = new core(core::YOLOFASTEST);
12
13
$server = new Swoole\WebSocket\Server("0.0.0.0", 8080);
0 ignored issues
show
Bug introduced by
The type Swoole\WebSocket\Server 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...
14
15
$server->on("start", function (Swoole\WebSocket\Server $server) {
0 ignored issues
show
Unused Code introduced by
The parameter $server is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

15
$server->on("start", function (/** @scrutinizer ignore-unused */ Swoole\WebSocket\Server $server) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
    echo "Swoole WebSocket Server is started at ws://0.0.0.0:8080\n";
17
});
18
19
$server->on('open', function(Swoole\WebSocket\Server $server, Swoole\Http\Request $request) {
0 ignored issues
show
Bug introduced by
The type Swoole\Http\Request 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...
20
    echo "connection open: {$request->fd}\n";
21
});
22
23
$server->on('message', function(Swoole\WebSocket\Server $server, Swoole\WebSocket\Frame $frame) use($dn) {
0 ignored issues
show
Bug introduced by
The type Swoole\WebSocket\Frame 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...
24
    echo "received: " . strlen($frame->data) . " bytes\n";
25
    foreach ($server->getClientList(0) as $client) {
26
        if ($frame->fd !== $client) {
27
            if ($dn->base64ImgDecode($frame->data) !== null) {
28
                $dn->remotePR($client, $frame, $server);
29
            }
30
        }
31
    }
32
});
33
34
$server->on('close', function(Swoole\WebSocket\Server $server, int $fd) {
35
    echo "connection close: {$fd}\n";
36
});
37
38
$server->start();
39