Implemented file sending during BINKP and EMSI sessions
This commit is contained in:
38
app/Classes/File/Tic.php
Normal file
38
app/Classes/File/Tic.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\File;
|
||||
|
||||
use App\Classes\FTN\Tic as FTNTic;
|
||||
use App\Models\{Address,File};
|
||||
|
||||
class Tic extends Item
|
||||
{
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct(Address $ao,File $fo,int $action)
|
||||
{
|
||||
$this->action |= $action;
|
||||
|
||||
$tic = new FTNTic;
|
||||
|
||||
switch ($action) {
|
||||
case self::I_SEND:
|
||||
$this->file = $tic->generate($ao,$fo);
|
||||
$this->file_type = self::IS_TIC;
|
||||
$this->file_name = sprintf('%s.tic',sprintf('%08x',$fo->id));
|
||||
$this->file_size = strlen($this->file);
|
||||
$this->file_mtime = $fo->created_at->timestamp;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new \Exception('Unknown action: '.$action);
|
||||
}
|
||||
}
|
||||
|
||||
public function read(int $start,int $length): string
|
||||
{
|
||||
return substr($this->file,$start,$length);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user