Changed to using new Address Model, Implemented Setup, Some minor CSS changes

This commit is contained in:
Deon George
2021-06-24 20:16:37 +10:00
parent ec6594b701
commit d1ca78d372
33 changed files with 766 additions and 172 deletions

View File

@@ -8,8 +8,7 @@ use Illuminate\Support\Facades\Log;
use App\Classes\File\{Receive,Send};
use App\Classes\Sock\SocketClient;
use App\Classes\Sock\SocketException;
use App\Models\Node as NodeModel;
use App\Models\Setup;
use App\Models\{Address,Setup};
abstract class Protocol
{
@@ -79,7 +78,7 @@ abstract class Protocol
protected const MO_CHAT = 4;
protected SocketClient $client; /* Our socket details */
protected Setup $setup; /* Our setup */
protected ?Setup $setup; /* Our setup */
protected Node $node; /* The node we are communicating with */
protected Send $send; /* The list of files we are sending */
protected Receive $recv; /* The list of files we are receiving */
@@ -92,6 +91,14 @@ abstract class Protocol
abstract protected function protocol_init(): int;
abstract protected function protocol_session(): int;
public function __construct(Setup $o=NULL)
{
if ($o && ! $o->system->addresses->count())
throw new Exception('We dont have any FTN addresses assigned');
$this->setup = $o;
}
/**
* @throws Exception
*/
@@ -181,11 +188,11 @@ abstract class Protocol
*
* @param int $type
* @param SocketClient $client
* @param NodeModel|null $o
* @param Address|null $o
* @return int
* @throws Exception
*/
public function session(int $type,SocketClient $client,NodeModel $o=NULL): int
public function session(int $type,SocketClient $client,Address $o=NULL): int
{
Log::debug(sprintf('%s: + Start [%d]',__METHOD__,$type));
@@ -198,9 +205,6 @@ abstract class Protocol
$this->recv = new Receive;
if ($o) {
// Our configuration and initialise values
$this->setup = Setup::findOrFail(self::setup);
// The node we are communicating with
$this->node = new Node;