WebSocketService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 5
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 15 1
1
<?php
2
3
namespace Shamaseen\Laravel\Ratchet\Commands;
4
5
use Shamaseen\Laravel\Ratchet\Receiver;
6
use Illuminate\Console\Command;
7
use Ratchet\Http\HttpServer;
8
use Ratchet\Server\IoServer;
9
use Ratchet\WebSocket\WsServer;
10
11
12
/**
13
 * Class ChatService
14
 * @package App\Console\Commands
15
 */
16
class WebSocketService extends Command
17
{
18
    /**
19
     * The name and signature of the console command.
20
     *
21
     * @var string
22
     */
23
    protected $signature = 'run:websocket';
24
25
    /**
26
     * The console command description.
27
     *
28
     * @var string
29
     */
30
    protected $description = 'start websocket';
31
32
    /**
33
     * Create a new command instance.
34
     *
35
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
36
     */
37
    public function __construct()
38
    {
39
        parent::__construct();
40
    }
41
42
    /**
43
     * Execute the console command.
44
     */
45
    public function handle()
46
    {
47
48
        $server = IoServer::factory(
49
            new HttpServer(
50
                new WsServer(
51
                    new Receiver()
52
                )
53
            ),
54
            env('WEBSOCKET_PORT',9090)
55
        );
56
57
        $this->info('Websocket is now running at port '.env('WEBSOCKET_PORT',9090));
58
        $server->run();
59
    }
60
}
61