Remove CommProtocolReceive commands, Remove protocol onConnect() functions, pass Setup::class to protocols
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Classes;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\File\{Receive,Send};
|
||||
@@ -138,9 +137,13 @@ abstract class Protocol
|
||||
|
||||
abstract protected function protocol_session(bool $force_queue=FALSE): int;
|
||||
|
||||
public function __construct()
|
||||
/**
|
||||
* @param Setup $setup
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(Setup $setup)
|
||||
{
|
||||
$this->setup = Config::get('setup',Setup::findOrFail(config('app.id')));
|
||||
$this->setup = $setup;
|
||||
|
||||
// Some initialisation details
|
||||
switch (get_class($this)) {
|
||||
@@ -267,20 +270,27 @@ abstract class Protocol
|
||||
* Incoming Protocol session
|
||||
*
|
||||
* @param SocketClient $client
|
||||
* @return int|null
|
||||
* @return int
|
||||
* @throws SocketException
|
||||
*/
|
||||
public function onConnect(SocketClient $client): ?int
|
||||
public function onConnect(SocketClient $client): int
|
||||
{
|
||||
$pid = pcntl_fork();
|
||||
|
||||
if ($pid === -1)
|
||||
throw new SocketException(SocketException::CANT_ACCEPT,'Could not fork process');
|
||||
|
||||
// If our parent returns a PID, we've forked
|
||||
if ($pid)
|
||||
Log::info(sprintf('%s:+ New connection from [%s], thread [%d] created',self::LOGKEY,$client->address_remote,$pid));
|
||||
|
||||
// Parent return ready for next connection
|
||||
// This is the new thread
|
||||
else {
|
||||
Log::withContext(['pid'=>getmypid()]);
|
||||
|
||||
$this->session($client,(new Address));
|
||||
}
|
||||
|
||||
return $pid;
|
||||
}
|
||||
|
||||
@@ -347,10 +357,10 @@ abstract class Protocol
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise our Session
|
||||
* Setup a session with a remote client
|
||||
*
|
||||
* @param SocketClient $client
|
||||
* @param Address|null $o
|
||||
* @param SocketClient $client Socket details of session
|
||||
* @param Address|null $o If we have an address, we originated a session to this Address
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
Reference in New Issue
Block a user