2021-04-01 10:59:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
2021-07-02 13:44:01 +00:00
|
|
|
use App\Classes\Protocol\Binkp;
|
2024-06-01 02:55:27 +00:00
|
|
|
use App\Classes\Sock\Exception\SocketException;
|
2021-04-01 10:59:15 +00:00
|
|
|
use App\Classes\Sock\SocketServer;
|
2021-06-24 10:16:37 +00:00
|
|
|
use App\Models\Setup;
|
2021-04-01 10:59:15 +00:00
|
|
|
|
2022-06-26 14:14:36 +00:00
|
|
|
class CommBinkpReceive extends Command
|
2021-04-01 10:59:15 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2022-06-26 14:14:36 +00:00
|
|
|
protected $signature = 'comm:binkp:receive';
|
2021-04-01 10:59:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'BINKP receive';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
2023-07-02 13:40:08 +00:00
|
|
|
* @throws SocketException
|
2021-04-01 10:59:15 +00:00
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
Log::info('Listening for BINKP connections...');
|
2023-07-02 13:40:08 +00:00
|
|
|
$o = Setup::findOrFail(config('app.id'));
|
2021-04-01 10:59:15 +00:00
|
|
|
|
2023-07-02 13:40:08 +00:00
|
|
|
$server = new SocketServer($o->binkp_port,$o->binkp_bind);
|
2024-11-04 02:06:04 +00:00
|
|
|
$server->handler = [new Binkp,'onConnect'];
|
2021-04-01 10:59:15 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
$server->listen();
|
|
|
|
|
|
|
|
} catch (SocketException $e) {
|
2023-06-27 07:39:11 +00:00
|
|
|
if ($e->getMessage() === 'Can\'t accept connections: "Success"')
|
2021-04-01 10:59:15 +00:00
|
|
|
Log::debug('Server Terminated');
|
|
|
|
else
|
|
|
|
Log::emergency('Uncaught Message: '.$e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|