From dee94bab3a74a238093c51252b74d609ae52d777 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Fri, 10 May 2019 13:49:16 +0200 Subject: [PATCH] CombinedAPI bugfixes --- src/danog/MadelineProto/CombinedAPI.php | 2 +- src/danog/MadelineProto/CombinedEventHandler.php | 12 ++++++++++-- .../MadelineProto/Loop/Connection/CheckLoop.php | 2 +- src/danog/MadelineProto/MTProto.php | 3 --- src/danog/MadelineProto/MTProtoTools/CallHandler.php | 5 ----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/danog/MadelineProto/CombinedAPI.php b/src/danog/MadelineProto/CombinedAPI.php index 8eae88da9..dd55e4276 100644 --- a/src/danog/MadelineProto/CombinedAPI.php +++ b/src/danog/MadelineProto/CombinedAPI.php @@ -186,7 +186,7 @@ class CombinedAPI if ($method === 'onLoop') { $this->loop_callback = [$this->event_handler_instance, 'onLoop']; } elseif ($method === 'onAny') { - foreach (end($this->instances)->API->constructors->by_id as $id => $constructor) { + foreach (end($this->instances)->API->constructors->by_id as $constructor) { if ($constructor['type'] === 'Update' && !isset($this->event_handler_methods[$constructor['predicate']])) { $this->event_handler_methods[$constructor['predicate']] = [$this->event_handler_instance, 'onAny']; } diff --git a/src/danog/MadelineProto/CombinedEventHandler.php b/src/danog/MadelineProto/CombinedEventHandler.php index 841008665..d4f6c2f03 100644 --- a/src/danog/MadelineProto/CombinedEventHandler.php +++ b/src/danog/MadelineProto/CombinedEventHandler.php @@ -35,8 +35,16 @@ abstract class CombinedEventHandler { $keys = method_exists($this, '__magic_sleep') ? $this->__magic_sleep() : get_object_vars($this); unset($keys['CombinedAPI']); - foreach ($this->CombinedAPI->instance_paths as $path) { - unset($keys[$path]); + if (isset($this->CombinedAPI)) { + foreach ($this->CombinedAPI->instance_paths as $path) { + unset($keys[$path]); + } + } else { + foreach ($keys as $key => $value) { + if ($value instanceof API) { + unset($keys[$key]); + } + } } return array_keys($keys); diff --git a/src/danog/MadelineProto/Loop/Connection/CheckLoop.php b/src/danog/MadelineProto/Loop/Connection/CheckLoop.php index fc05acb78..1c9e3df54 100644 --- a/src/danog/MadelineProto/Loop/Connection/CheckLoop.php +++ b/src/danog/MadelineProto/Loop/Connection/CheckLoop.php @@ -105,7 +105,7 @@ class CheckLoop extends ResumableSignalLoop } } if ($reply) { - $API->object_call('msg_resend_ans_req', ['msg_ids' => $reply], ['datacenter' => $datacenter, 'postpone' => true]); + $API->object_call_async('msg_resend_ans_req', ['msg_ids' => $reply], ['datacenter' => $datacenter, 'postpone' => true]); } $connection->writer->resume(); } diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index cf2312a36..c8ba4fffe 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -819,9 +819,6 @@ class MTProto implements TLCallback public function close_and_reopen($datacenter) { $this->wait($this->datacenter->sockets[$datacenter]->reconnect()); - /*if ($this->is_http($datacenter) && $this->datacenter->sockets[$datacenter]->temp_auth_key !== null && isset($this->datacenter->sockets[$datacenter]->temp_auth_key['connection_inited']) && $this->datacenter->sockets[$datacenter]->temp_auth_key['connection_inited'] === true) { - $this->method_call('ping', ['ping_id' => 0], ['datacenter' => $datacenter]); - }*/ } // Connects to all datacenters and if necessary creates authorization keys, binds them and writes client info diff --git a/src/danog/MadelineProto/MTProtoTools/CallHandler.php b/src/danog/MadelineProto/MTProtoTools/CallHandler.php index e3b19f8ec..1145b7ba0 100644 --- a/src/danog/MadelineProto/MTProtoTools/CallHandler.php +++ b/src/danog/MadelineProto/MTProtoTools/CallHandler.php @@ -170,11 +170,6 @@ trait CallHandler return $deferred; } - public function object_call($object, $args = [], $aargs = ['msg_id' => null, 'heavy' => false]) - { - return $this->wait($this->object_call_async($object, $args, $aargs)); - } - public function object_call_async($object, $args = [], $aargs = ['msg_id' => null, 'heavy' => false]): Promise { $message = ['_' => $object, 'body' => $args, 'content_related' => $this->content_related($object), 'unencrypted' => $this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key === null, 'method' => false];