clrghouz/app/Console/Commands/CommEMSIReceive.php
Deon George 7aecbe2f6e
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 28s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m30s
Create Docker Image / Final Docker Image Manifest (push) Successful in 8s
Fix for 3b7ce4b, change where setup is defined for our protocols
2024-11-04 13:06:04 +11:00

54 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use App\Classes\Protocol\EMSI;
use App\Classes\Sock\Exception\SocketException;
use App\Classes\Sock\SocketServer;
use App\Models\Setup;
class CommEMSIReceive extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'comm:emsi:receive';
/**
* The console command description.
*
* @var string
*/
protected $description = 'EMSI receive';
/**
* Execute the console command.
*
* @return mixed
* @throws \Exception
*/
public function handle()
{
Log::info('Listening for EMSI connections...');
$o = Setup::findOrFail(config('app.id'));
$server = new SocketServer($o->emsi_port,$o->emsi_bind);
$server->handler = [new EMSI,'onConnect'];
try {
$server->listen();
} catch (SocketException $e) {
if ($e->getMessage() === 'Can\'t accept connections: "Success"')
Log::debug('Server Terminated');
else
Log::emergency('Uncaught Message: '.$e->getMessage());
}
}
}