clrghouz/app/Console/Commands/EMSIReceive.php
2021-06-13 01:32:22 +10:00

52 lines
995 B
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;
use App\Classes\Sock\SocketException;
use App\Classes\Sock\SocketServer;
use App\Classes\Protocol\EMSI as EMSIClass;
class EMSIReceive extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'emsi:receive';
/**
* The console command description.
*
* @var string
*/
protected $description = 'EMSI receive';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Log::info('Listening for EMSI connections...');
$server = new SocketServer(60179,'0.0.0.0');
$server->setConnectionHandler([new EMSIClass,'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());
}
}
}