Make the stream API generic again
This commit is contained in:
parent
0a33f69e8b
commit
d82914187c
@ -507,7 +507,24 @@ class DataCenter
|
||||
|
||||
foreach ($combo as $stream) {
|
||||
if ($stream[0] === DefaultStream::getName() && $stream[1] === []) {
|
||||
$stream[1] = [[$this, 'socketConnect'], [$this, 'cryptoConnect']];
|
||||
$isIpv6 = $ipv6 === 'ipv6';
|
||||
$stream[1] = [
|
||||
function (
|
||||
string $uri,
|
||||
ClientConnectContext $socketContext = null,
|
||||
CancellationToken $token = null
|
||||
) use ($isIpv6): Promise {
|
||||
return $this->socketConnect($isIpv6, $uri, $socketContext, $token);
|
||||
},
|
||||
function (
|
||||
string $uri,
|
||||
ClientConnectContext $socketContext = null,
|
||||
ClientTlsContext $tlsContext = null,
|
||||
CancellationToken $token = null
|
||||
) use ($isIpv6): Promise {
|
||||
return $this->cryptoConnect($isIpv6, $uri, $socketContext, $tlsContext, $token);
|
||||
}
|
||||
];
|
||||
}
|
||||
$ctx->addStream(...$stream);
|
||||
}
|
||||
@ -567,7 +584,24 @@ class DataCenter
|
||||
|
||||
foreach ($combo as $stream) {
|
||||
if ($stream[0] === DefaultStream::getName() && $stream[1] === []) {
|
||||
$stream[1] = [[$this, 'socketConnect'], [$this, 'cryptoConnect']];
|
||||
$isIpv6 = $ipv6 === 'ipv6';
|
||||
$stream[1] = [
|
||||
function (
|
||||
string $uri,
|
||||
ClientConnectContext $socketContext = null,
|
||||
CancellationToken $token = null
|
||||
) use ($isIpv6): Promise {
|
||||
return $this->socketConnect($isIpv6, $uri, $socketContext, $token);
|
||||
},
|
||||
function (
|
||||
string $uri,
|
||||
ClientConnectContext $socketContext = null,
|
||||
ClientTlsContext $tlsContext = null,
|
||||
CancellationToken $token = null
|
||||
) use ($isIpv6): Promise {
|
||||
return $this->cryptoConnect($isIpv6, $uri, $socketContext, $tlsContext, $token);
|
||||
}
|
||||
];
|
||||
}
|
||||
$ctx->addStream(...$stream);
|
||||
}
|
||||
|
@ -57,9 +57,9 @@ class DefaultStream extends Socket implements RawStreamInterface, ProxyStreamInt
|
||||
public function connectAsync(\danog\MadelineProto\Stream\ConnectionContext $ctx, string $header = ''): \Generator
|
||||
{
|
||||
if ($ctx->isSecure()) {
|
||||
$this->stream = yield ($this->cryptoConnector)($ctx->getIpv6(), $ctx->getStringUri(), $ctx->getSocketContext(), null, $ctx->getCancellationToken());
|
||||
$this->stream = yield ($this->cryptoConnector)($ctx->getStringUri(), $ctx->getSocketContext(), null, $ctx->getCancellationToken());
|
||||
} else {
|
||||
$this->stream = yield ($this->connector)($ctx->getIpv6(), $ctx->getStringUri(), $ctx->getSocketContext(), $ctx->getCancellationToken());
|
||||
$this->stream = yield ($this->connector)($ctx->getStringUri(), $ctx->getSocketContext(), $ctx->getCancellationToken());
|
||||
}
|
||||
yield $this->stream->write($header);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user