ghostjat /
php-darknet
| 1 | <?php |
||
| 2 | require __DIR__.'/../vendor/autoload.php'; |
||
| 3 | |||
| 4 | use Ratchet\MessageComponentInterface; |
||
|
0 ignored issues
–
show
|
|||
| 5 | use Ratchet\ConnectionInterface; |
||
|
0 ignored issues
–
show
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. 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
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. 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
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. 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
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. 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 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths