改名
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Server\Constrict;
|
namespace Server\Constrict;
|
||||||
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Server\ResponseInterface;
|
||||||
|
|
||||||
interface Emitter
|
interface Emitter
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -307,4 +307,22 @@ class Response implements ResponseInterface
|
|||||||
{
|
{
|
||||||
return $this->__call__()->{__FUNCTION__}();
|
return $this->__call__()->{__FUNCTION__}();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getClientId(): int
|
||||||
|
{
|
||||||
|
return $this->__call__()->{__FUNCTION__}();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getClientInfo(): array
|
||||||
|
{
|
||||||
|
return $this->__call__()->{__FUNCTION__}();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace Server\Constrict;
|
namespace Server\Constrict;
|
||||||
|
|
||||||
use Annotation\Inject;
|
use Annotation\Inject;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Server\ResponseInterface;
|
||||||
use Server\RequestInterface;
|
use Server\RequestInterface;
|
||||||
use Server\SInterface\DownloadInterface;
|
use Server\SInterface\DownloadInterface;
|
||||||
use Swoole\Server;
|
use Swoole\Server;
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace Server\Constrict;
|
namespace Server\Constrict;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Http\Context\Formatter\FileFormatter;
|
use Http\Context\Formatter\FileFormatter;
|
||||||
use Kiri\Exception\NotFindClassException;
|
use Server\ResponseInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
|
||||||
use Swoole\Server;
|
use Swoole\Server;
|
||||||
|
|
||||||
|
|
||||||
@@ -18,17 +18,15 @@ class TcpEmitter implements Emitter
|
|||||||
/**
|
/**
|
||||||
* @param Server $response
|
* @param Server $response
|
||||||
* @param ResponseInterface $emitter
|
* @param ResponseInterface $emitter
|
||||||
* @throws NotFindClassException
|
* @throws Exception
|
||||||
* @throws \ReflectionException
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function sender(mixed $response, ResponseInterface $emitter): void
|
public function sender(mixed $response, ResponseInterface $emitter): void
|
||||||
{
|
{
|
||||||
$formatter = $emitter->getContent();
|
$formatter = $emitter->stream->getContents();
|
||||||
if ($formatter instanceof FileFormatter) {
|
if ($formatter instanceof FileFormatter) {
|
||||||
$response->sendfile($emitter->getClientId(), $formatter->getData());
|
$response->sendfile($emitter->getClientId(), $formatter);
|
||||||
} else {
|
} else {
|
||||||
$response->send($emitter->getClientId(), $formatter->getData());
|
$response->send($emitter->getClientId(), $formatter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace Server\Constrict;
|
namespace Server\Constrict;
|
||||||
|
|
||||||
use Kiri\Exception\NotFindClassException;
|
use Kiri\Exception\NotFindClassException;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Server\ResponseInterface;
|
||||||
use Swoole\Server;
|
use Swoole\Server;
|
||||||
|
|
||||||
|
|
||||||
@@ -17,15 +17,13 @@ class UdpEmitter implements Emitter
|
|||||||
/**
|
/**
|
||||||
* @param Server $response
|
* @param Server $response
|
||||||
* @param ResponseInterface $emitter
|
* @param ResponseInterface $emitter
|
||||||
* @throws NotFindClassException
|
|
||||||
* @throws \ReflectionException
|
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function sender(mixed $response, ResponseInterface $emitter): void
|
public function sender(mixed $response, ResponseInterface $emitter): void
|
||||||
{
|
{
|
||||||
$clientInfo = $emitter->getClientInfo();
|
$clientInfo = $emitter->getClientInfo();
|
||||||
$response->sendto($clientInfo['host'], $clientInfo['port'],
|
$response->sendto($clientInfo['host'], $clientInfo['port'],
|
||||||
$emitter->getContent()->getData()
|
$emitter->stream->getContents()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ namespace Server\Constrict;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Kiri;
|
use Kiri\Kiri;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
|
||||||
use Server\ServerManager;
|
use Server\ServerManager;
|
||||||
|
use Server\ResponseInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ interface ResponseInterface extends \Psr\Http\Message\ResponseInterface
|
|||||||
public function file(string $path): DownloadInterface;
|
public function file(string $path): DownloadInterface;
|
||||||
|
|
||||||
|
|
||||||
|
public function getClientId(): int;
|
||||||
|
public function getClientInfo(): array;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $responseData
|
* @param $responseData
|
||||||
* @return string|array|bool|int|null
|
* @return string|array|bool|int|null
|
||||||
|
|||||||
Reference in New Issue
Block a user