Move address polling to a Job, better catch Socket connection refused errors
This commit is contained in:
@@ -6,9 +6,8 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\Protocol\Binkp;
|
||||
use App\Classes\Sock\SocketClient;
|
||||
use App\Models\{Address,Setup};
|
||||
use App\Models\Address;
|
||||
use App\Jobs\AddressPoll as Job;
|
||||
|
||||
class BinkpSend extends Command
|
||||
{
|
||||
@@ -29,29 +28,16 @@ class BinkpSend extends Command
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \App\Classes\Sock\SocketException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(): void
|
||||
{
|
||||
Log::info('Call BINKP send');
|
||||
|
||||
$no = Address::findFTN($this->argument('ftn'));
|
||||
if (! $no)
|
||||
$ao = Address::findFTN($this->argument('ftn'));
|
||||
if (! $ao)
|
||||
throw new ModelNotFoundException('Unknown node: '.$this->argument('ftn'));
|
||||
|
||||
if ($no->system->mailer_type != Setup::O_BINKP)
|
||||
throw new \Exception(sprintf('Node [%s] doesnt support BINKD',$this->argument('ftn')));
|
||||
|
||||
if ((! $no->system->mailer_address) || (! $no->system->mailer_port))
|
||||
throw new \Exception(sprintf('Unable to poll [%s] missing mailer details',$this->argument('ftn')));
|
||||
|
||||
$client = SocketClient::create($no->system->mailer_address,$no->system->mailer_port);
|
||||
|
||||
$o = new Binkp(Setup::findOrFail(config('app.id')));
|
||||
$o->session(Binkp::SESSION_BINKP,$client,$no);
|
||||
|
||||
Log::info(sprintf('Connection ended: %s',$client->address_remote),['m'=>__METHOD__]);
|
||||
Job::dispatchSync($ao);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user