Conditions | 3 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
38 | public function start(): void { |
||
39 | if ($this->tcpServer !== null) { |
||
40 | return; |
||
41 | } |
||
42 | |||
43 | $ip = $this->config['ip'] ?? '0.0.0.0'; |
||
44 | $port = $this->config['port'] ?? '2341'; |
||
45 | |||
46 | $this->tcpServer = new \React\Socket\TcpServer($ip . ':' . $port); |
||
47 | |||
48 | $this->tcpServer->on('connection', function (ConnectionInterface $connection) { |
||
49 | |||
50 | $connection->pipe($connection); |
||
51 | |||
52 | $connection->on('data', function ($payload) { |
||
53 | foreach ($this->listeners as $listener) { |
||
54 | $listener->handle($payload); |
||
55 | } |
||
74 | } |