Ferreteria/v0.6/clade/IO/Aspect/Connx/Stream/Finite/Buffer/Conveyer/Sender
Jump to navigation
Jump to search
|
The item documented here has been removed and is no longer in use. As of 2026-02-04, it does not seem to be needed.
|
Code
<?php namespace Woozalia\Ferret\IO\Aspect\Connx\Stream\Buffer\Conveyer;
// 2026-01-11 Is this even being used? ActionIface is used, but it should be HowIface...
/* Base* [ca,i] */ use Woozalia\Ferret\IO\Aspect\Connx\Stream\Buffer\{ cConveyer as BaseClass, iConveyer as BaseIface };
/* How* [c,i] */ use Woozalia\Ferret\IO\Aspect\Connx\aux\{ cItWent as HowClass, iItWent as HowIface };
/* LoggerIface */ use Woozalia\Ferret\Sys\FileSys\Aspect\InOut\Fi\iLog as LoggerIface;
/* StreamIface */ use Woozalia\Ferret\IO\Aspect\Connx\iStream as StreamIface;
interface iSender extends BaseIface {
// I/O
function SendIt(string $s, StreamIface $o) : ActionIface; // send $s to $o in smaller bursts
}
class cSender extends BaseClass implements iSender {
// ++ CONFIG ++ //
const OBUFF_SIZE = 1024; // 1k output buffer
#const OBUFF_SIZE = 1024*64; // 64k output buffer
// -- CONFIG -- //
// ++ I/O ++ //
// 2026-01-11 Is this still being used? $ok is used inconsistently. TODO
public function SendIt(string $s, StreamIface $o) : ActionIface {
$this->AmHere('Is this being called?');
$sRem = $s;
$ok = TRUE;
$nTot = 0;
while ($ok && ($sRem !== '')) {
$sNow = substr($sRem,0,self::OBUFF_SIZE); // get burst to send
$ok = $o->PushBytes($sNow); // try to send it
$n = strlen($s); // how much got sent?
$nTot += $n;
$sRem = substr($sRem,$n); // remove bytes-sent from local buffer
$this->OnChange();
}
$this->LogEntry('REQUEST: '.strlen($s)." / SENT: $nTot");
return $ok;
}
// -- I/O -- //
// ++ UI OUTPUT ++ //
// 2026-01-02 I just copied this from cFinite -- it needs to be modified.
public function DescribeInline() : string {
$nlRem = $this->NTotalBytes();
$sS = ($nlRem === 1) ? '' : 's';
return "$nlRem byte$sS in ".$this->SType();
}
// -- UI OUTPUT -- //
// ++ LOGGING ++ //
protected function LogEntry(string $s) {
if (is_object($this->oLog)) {
$this->oLog->WriteEntry($s);
}
}
// -- LOGGING -- //
}