Ferreteria/v0.6/clade/IO/Aspect/Connx/Plug
Jump to navigation
Jump to search
| ||||||||||||||
About
- PURPOSE: a connection that expects access to a socket
History
Code
as of 2025-10-21
interface iPlug extends BaseIface {
// CONFIG
function ActionClass(string $sc=NULL) : string;
// SETUP
static function FromSocket(SockIface $oSock) : self;
static function ForSocket() : self;
// SETUP: dynamic
function DefaultSocket(SockIface $o) : void;
// I/O
function DoCommand(string|array $sCmd, BufferIface $oBuff, ?CommOpIface $oAct=NULL) : CommOpIface;
}
abstract class caPlug extends BaseClass implements SelfIface {
// ++ CONFIG ++ //
private $scAct = CommOpClass::class;
// PUBLIC so it can be changed externally
public function ActionClass(string $sc=NULL) : string { return is_string($sc) ? ($this->scAct = $sc) : $this->scAct; }
// -- CONFIG -- //
// ++ SETUP ++ //
protected function __construct(){}
// ++ SETUP: dynamic ++ //
static public function FromSocket(SockIface $oSock) : SelfIface {
$oThis = new static;
$oThis->WithSocket($oSock);
return $oThis;
}
static public function ForSocket() : SelfIface { return new static; }
private $oSock=NULL;
protected function WithSocket(SockIface $o) : void { $this->oSock = $o; }
public function DefaultSocket(SockIface $o) : void { if (is_null($this->oSock)) $this->oSock = $o; }
protected function OSock() : SockIface { return $this->oSock; }
// -- SETUP -- //
}