改名
This commit is contained in:
@@ -34,6 +34,17 @@ class Http2 extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $timeout
|
||||||
|
* @return Http2
|
||||||
|
*/
|
||||||
|
public function setTimeout(int $timeout): static
|
||||||
|
{
|
||||||
|
Context::setContext('http2timeout', $timeout);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $headers
|
* @param array $headers
|
||||||
* @return Http2
|
* @return Http2
|
||||||
@@ -153,7 +164,11 @@ class Http2 extends Component
|
|||||||
private function recv($client): mixed
|
private function recv($client): mixed
|
||||||
{
|
{
|
||||||
/** @var Response $response */
|
/** @var Response $response */
|
||||||
$response = $client->recv();
|
if (!Context::hasContext('http2timeout')) {
|
||||||
|
$response = $client->recv();
|
||||||
|
} else {
|
||||||
|
$response = $client->recv((int)Context::getContext('http2timeout'));
|
||||||
|
}
|
||||||
if ($response === false || $response->statusCode > 200) {
|
if ($response === false || $response->statusCode > 200) {
|
||||||
throw new Exception($client->errMsg, $client->errCode);
|
throw new Exception($client->errMsg, $client->errCode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class OnPacket extends Callback
|
|||||||
$dispatch = $node->dispatch();
|
$dispatch = $node->dispatch();
|
||||||
if (!is_string($dispatch)) $dispatch = Json::encode($dispatch);
|
if (!is_string($dispatch)) $dispatch = Json::encode($dispatch);
|
||||||
if (empty($dispatch)) {
|
if (empty($dispatch)) {
|
||||||
return true;
|
$dispatch = Json::encode(['state' => 0, 'message' => 'ok']);
|
||||||
}
|
}
|
||||||
return $server->sendto($host, $port, $dispatch);
|
return $server->sendto($host, $port, $dispatch);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class OnReceive extends Callback
|
|||||||
$dispatch = $node->dispatch();
|
$dispatch = $node->dispatch();
|
||||||
if (!is_string($dispatch)) $dispatch = Json::encode($dispatch);
|
if (!is_string($dispatch)) $dispatch = Json::encode($dispatch);
|
||||||
if (empty($dispatch)) {
|
if (empty($dispatch)) {
|
||||||
return true;
|
$dispatch = Json::encode(['state' => 0, 'message' => 'ok']);
|
||||||
}
|
}
|
||||||
return $server->send($fd, $dispatch);
|
return $server->send($fd, $dispatch);
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
|
|||||||
Reference in New Issue
Block a user