clrghouz/app/Console/Commands/CommBinkpReceive.php

52 lines
1.0 KiB
PHP
Raw Normal View History

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;
2021-04-01 10:59:15 +00:00
use App\Classes\Sock\SocketException;
use App\Classes\Sock\SocketServer;
use App\Models\Setup;
2021-04-01 10:59:15 +00:00
class CommBinkpReceive extends Command
2021-04-01 10:59:15 +00:00
{
/**
* The name and signature of the console command.
*
* @var string
*/
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
*/
public function handle()
{
Log::info('Listening for BINKP connections...');
$server = new SocketServer(Setup::BINKP_PORT,Setup::BINKP_BIND);
2021-07-02 13:44:01 +00:00
$server->setConnectionHandler([new Binkp(Setup::findOrFail(config('app.id'))),'onConnect']);
2021-04-01 10:59:15 +00:00
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());
}
}
}