CombinedAPI bugfixes

This commit is contained in:
Daniil Gentili 2019-05-10 13:49:16 +02:00
parent c993f4d207
commit dee94bab3a
5 changed files with 12 additions and 12 deletions

View File

@ -186,7 +186,7 @@ class CombinedAPI
if ($method === 'onLoop') { if ($method === 'onLoop') {
$this->loop_callback = [$this->event_handler_instance, 'onLoop']; $this->loop_callback = [$this->event_handler_instance, 'onLoop'];
} elseif ($method === 'onAny') { } 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']])) { if ($constructor['type'] === 'Update' && !isset($this->event_handler_methods[$constructor['predicate']])) {
$this->event_handler_methods[$constructor['predicate']] = [$this->event_handler_instance, 'onAny']; $this->event_handler_methods[$constructor['predicate']] = [$this->event_handler_instance, 'onAny'];
} }

View File

@ -35,8 +35,16 @@ abstract class CombinedEventHandler
{ {
$keys = method_exists($this, '__magic_sleep') ? $this->__magic_sleep() : get_object_vars($this); $keys = method_exists($this, '__magic_sleep') ? $this->__magic_sleep() : get_object_vars($this);
unset($keys['CombinedAPI']); unset($keys['CombinedAPI']);
foreach ($this->CombinedAPI->instance_paths as $path) { if (isset($this->CombinedAPI)) {
unset($keys[$path]); 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); return array_keys($keys);

View File

@ -105,7 +105,7 @@ class CheckLoop extends ResumableSignalLoop
} }
} }
if ($reply) { 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(); $connection->writer->resume();
} }

View File

@ -819,9 +819,6 @@ class MTProto implements TLCallback
public function close_and_reopen($datacenter) public function close_and_reopen($datacenter)
{ {
$this->wait($this->datacenter->sockets[$datacenter]->reconnect()); $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 // Connects to all datacenters and if necessary creates authorization keys, binds them and writes client info

View File

@ -170,11 +170,6 @@ trait CallHandler
return $deferred; 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 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]; $message = ['_' => $object, 'body' => $args, 'content_related' => $this->content_related($object), 'unencrypted' => $this->datacenter->sockets[$aargs['datacenter']]->temp_auth_key === null, 'method' => false];