Link eventHandler APIFactory
This commit is contained in:
parent
997b3d3b3b
commit
38382bf053
@ -136,6 +136,7 @@ class API extends InternalDoc
|
|||||||
$unserialized->session = $session;
|
$unserialized->session = $session;
|
||||||
APIWrapper::link($this, $unserialized);
|
APIWrapper::link($this, $unserialized);
|
||||||
APIWrapper::link($this->wrapper, $this);
|
APIWrapper::link($this->wrapper, $this);
|
||||||
|
AbstractAPIFactory::link($this->wrapper->getFactory(), $this);
|
||||||
if (isset($this->API)) {
|
if (isset($this->API)) {
|
||||||
$this->storage = $this->API->storage ?? $this->storage;
|
$this->storage = $this->API->storage ?? $this->storage;
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ use Amp\Http\Client\HttpClientBuilder;
|
|||||||
use Amp\Http\Client\Request;
|
use Amp\Http\Client\Request;
|
||||||
use Amp\Socket\ConnectContext;
|
use Amp\Socket\ConnectContext;
|
||||||
use Amp\Socket\DnsConnector;
|
use Amp\Socket\DnsConnector;
|
||||||
|
use Amp\Websocket\Client\Handshake;
|
||||||
use Amp\Websocket\Client\Rfc6455Connector;
|
use Amp\Websocket\Client\Rfc6455Connector;
|
||||||
use danog\MadelineProto\MTProto\PermAuthKey;
|
use danog\MadelineProto\MTProto\PermAuthKey;
|
||||||
use danog\MadelineProto\MTProto\TempAuthKey;
|
use danog\MadelineProto\MTProto\TempAuthKey;
|
||||||
@ -233,7 +234,9 @@ class DataCenter
|
|||||||
$this->nonProxiedDoHClient = Magic::$altervista || Magic::$zerowebhost ? new Rfc1035StubResolver() : new Rfc8484StubResolver($nonProxiedDoHConfig);
|
$this->nonProxiedDoHClient = Magic::$altervista || Magic::$zerowebhost ? new Rfc1035StubResolver() : new Rfc8484StubResolver($nonProxiedDoHConfig);
|
||||||
|
|
||||||
$this->dnsConnector = new DnsConnector(new Rfc1035StubResolver());
|
$this->dnsConnector = new DnsConnector(new Rfc1035StubResolver());
|
||||||
$this->webSocketConnnector = new Rfc6455Connector($this->HTTPClient);
|
if (\class_exists(Rfc6455Connector::class)) {
|
||||||
|
$this->webSocketConnnector = new Rfc6455Connector($this->HTTPClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function dcConnect(string $dc_number, int $id = -1): \Generator
|
public function dcConnect(string $dc_number, int $id = -1): \Generator
|
||||||
@ -265,7 +268,7 @@ class DataCenter
|
|||||||
if (\MADELINEPROTO_TEST === 'pony') {
|
if (\MADELINEPROTO_TEST === 'pony') {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
$this->API->logger->logger("Connection failed ({$dc_number}): " . $e->getMessage(), \danog\MadelineProto\Logger::ERROR);
|
$this->API->logger->logger("Connection failed ({$dc_number}): ".$e->getMessage(), \danog\MadelineProto\Logger::ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Exception("Could not connect to DC {$dc_number}");
|
throw new Exception("Could not connect to DC {$dc_number}");
|
||||||
@ -468,6 +471,9 @@ class DataCenter
|
|||||||
$stream[1] = $useDoH ? new DoHConnector($this, $ctx) : $this->dnsConnector;
|
$stream[1] = $useDoH ? new DoHConnector($this, $ctx) : $this->dnsConnector;
|
||||||
}
|
}
|
||||||
if (\in_array($stream[0], [WsStream::class, WssStream::class]) && $stream[1] === []) {
|
if (\in_array($stream[0], [WsStream::class, WssStream::class]) && $stream[1] === []) {
|
||||||
|
if (!\class_exists(Handshake::class)) {
|
||||||
|
throw new Exception('Please install amphp/websocket-client by running "composer require amphp/websocket-client:dev-master"');
|
||||||
|
}
|
||||||
$stream[1] = $this->webSocketConnnector;
|
$stream[1] = $this->webSocketConnnector;
|
||||||
}
|
}
|
||||||
$ctx->addStream(...$stream);
|
$ctx->addStream(...$stream);
|
||||||
@ -477,8 +483,8 @@ class DataCenter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($this->dclist[$test][$ipv6][$dc_number . '_bk']['ip_address'])) {
|
if (isset($this->dclist[$test][$ipv6][$dc_number.'_bk']['ip_address'])) {
|
||||||
$ctxs = \array_merge($ctxs, $this->generateContexts($dc_number . '_bk'));
|
$ctxs = \array_merge($ctxs, $this->generateContexts($dc_number.'_bk'));
|
||||||
}
|
}
|
||||||
if (empty($ctxs)) {
|
if (empty($ctxs)) {
|
||||||
unset($this->sockets[$dc_number]);
|
unset($this->sockets[$dc_number]);
|
||||||
|
@ -138,7 +138,7 @@ class FeedLoop extends ResumableSignalLoop
|
|||||||
foreach ($updates as $update) {
|
foreach ($updates as $update) {
|
||||||
$res = $this->feedSingle($update);
|
$res = $this->feedSingle($update);
|
||||||
if ($res instanceof \Generator) {
|
if ($res instanceof \Generator) {
|
||||||
$res = yield $res;
|
$res = yield from $res;
|
||||||
}
|
}
|
||||||
$result[$res] = true;
|
$result[$res] = true;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
namespace danog\MadelineProto\Wrappers;
|
namespace danog\MadelineProto\Wrappers;
|
||||||
|
|
||||||
use danog\MadelineProto\EventHandler;
|
use danog\MadelineProto\EventHandler;
|
||||||
|
use danog\MadelineProto\Tools;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event handler.
|
* Event handler.
|
||||||
@ -84,6 +85,9 @@ trait Events
|
|||||||
$this->settings['updates']['callback'] = [$this, 'eventUpdateHandler'];
|
$this->settings['updates']['callback'] = [$this, 'eventUpdateHandler'];
|
||||||
$this->settings['updates']['handle_updates'] = true;
|
$this->settings['updates']['handle_updates'] = true;
|
||||||
$this->settings['updates']['run_callback'] = true;
|
$this->settings['updates']['run_callback'] = true;
|
||||||
|
if (method_exists($this->event_handler_instance, 'onStart')) {
|
||||||
|
Tools::callFork($this->event_handler_instance->onStart());
|
||||||
|
}
|
||||||
if ($this->inited()) {
|
if ($this->inited()) {
|
||||||
$this->startUpdateSystem();
|
$this->startUpdateSystem();
|
||||||
}
|
}
|
||||||
|
@ -220,4 +220,4 @@ trait Loop
|
|||||||
\fastcgi_finish_request();
|
\fastcgi_finish_request();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,13 @@ composer config platform.php "7.4"
|
|||||||
composer clearcache
|
composer clearcache
|
||||||
composer update
|
composer update
|
||||||
composer require amphp/mysql
|
composer require amphp/mysql
|
||||||
[ $PHP_MAJOR_VERSION -eq 5 ] && composer require dstuecken/php7ify && composer require symfony/polyfill-php70
|
[ $PHP_MAJOR_VERSION -eq 5 ] && {
|
||||||
|
composer require dstuecken/php7ify
|
||||||
|
composer require symfony/polyfill-php70
|
||||||
|
composer require symfony/polyfill-php71
|
||||||
|
composer require symfony/polyfill-php72
|
||||||
|
composer require symfony/polyfill-php73
|
||||||
|
}
|
||||||
[ $PHP_MAJOR_VERSION -eq 7 ] && [ $PHP_MINOR_VERSION -eq 0 ] && {
|
[ $PHP_MAJOR_VERSION -eq 7 ] && [ $PHP_MINOR_VERSION -eq 0 ] && {
|
||||||
composer require symfony/polyfill-php71
|
composer require symfony/polyfill-php71
|
||||||
composer require symfony/polyfill-php72
|
composer require symfony/polyfill-php72
|
||||||
|
Loading…
Reference in New Issue
Block a user