Performance improvements
This commit is contained in:
parent
59bf76aefa
commit
dcb63a2f6d
@ -139,7 +139,6 @@ trait PeerHandler
|
|||||||
|
|
||||||
public function cache_pwr_chat($id, $full_fetch, $send)
|
public function cache_pwr_chat($id, $full_fetch, $send)
|
||||||
{
|
{
|
||||||
Loop::defer(function () use ($id, $full_fetch, $send) {
|
|
||||||
$this->call((function () use ($id, $full_fetch, $send) {
|
$this->call((function () use ($id, $full_fetch, $send) {
|
||||||
try {
|
try {
|
||||||
yield $this->get_pwr_chat_async($id, $full_fetch, $send);
|
yield $this->get_pwr_chat_async($id, $full_fetch, $send);
|
||||||
@ -149,7 +148,6 @@ trait PeerHandler
|
|||||||
$this->logger->logger("While caching: ".$e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
$this->logger->logger("While caching: ".$e->getMessage(), \danog\MadelineProto\Logger::WARNING);
|
||||||
}
|
}
|
||||||
})());
|
})());
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function peer_isset_async($id)
|
public function peer_isset_async($id)
|
||||||
|
@ -113,7 +113,8 @@ trait ResponseHandler
|
|||||||
|
|
||||||
// Acknowledge that I received the server's response
|
// Acknowledge that I received the server's response
|
||||||
if ($this->authorized === self::LOGGED_IN && !$this->initing_authorization && $this->datacenter->sockets[$this->datacenter->curdc]->temp_auth_key !== null) {
|
if ($this->authorized === self::LOGGED_IN && !$this->initing_authorization && $this->datacenter->sockets[$this->datacenter->curdc]->temp_auth_key !== null) {
|
||||||
Loop::defer(function () { $this->call($this->get_updates_difference_async()); });
|
|
||||||
|
$this->call($this->get_updates_difference_async());
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']);
|
unset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']);
|
||||||
@ -256,9 +257,7 @@ trait ResponseHandler
|
|||||||
unset($this->datacenter->sockets[$datacenter]->new_incoming[$current_msg_id]);
|
unset($this->datacenter->sockets[$datacenter]->new_incoming[$current_msg_id]);
|
||||||
|
|
||||||
if (strpos($datacenter, 'cdn') === false) {
|
if (strpos($datacenter, 'cdn') === false) {
|
||||||
$updates = $this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content'];
|
$this->call($this->handle_updates_async($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']));
|
||||||
Loop::defer(function () use ($updates) { $this->call($this->handle_updates_async($updates)); });
|
|
||||||
unset($updates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']);
|
unset($this->datacenter->sockets[$datacenter]->incoming_messages[$current_msg_id]['content']);
|
||||||
@ -399,13 +398,11 @@ trait ResponseHandler
|
|||||||
$this->authorized = self::NOT_LOGGED_IN;
|
$this->authorized = self::NOT_LOGGED_IN;
|
||||||
$this->authorization = null;
|
$this->authorization = null;
|
||||||
|
|
||||||
Loop::defer(function () use ($datacenter, &$request, &$response) {
|
$this->call((function () use ($datacenter, &$request, &$response) {
|
||||||
$this->call((function () use ($datacenter, &$request, &$response) {
|
yield $this->init_authorization_async();
|
||||||
yield $this->init_authorization_async();
|
|
||||||
|
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
||||||
})());
|
})());
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
case 'AUTH_KEY_UNREGISTERED':
|
case 'AUTH_KEY_UNREGISTERED':
|
||||||
@ -413,13 +410,11 @@ trait ResponseHandler
|
|||||||
if ($this->authorized !== self::LOGGED_IN) {
|
if ($this->authorized !== self::LOGGED_IN) {
|
||||||
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
||||||
|
|
||||||
Loop::defer(function () use ($datacenter, &$request, &$response) {
|
$this->call((function () use ($datacenter, &$request, &$response) {
|
||||||
$this->call((function () use ($datacenter, &$request, &$response) {
|
yield $this->init_authorization_async();
|
||||||
yield $this->init_authorization_async();
|
|
||||||
|
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
||||||
})());
|
})());
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -450,35 +445,29 @@ trait ResponseHandler
|
|||||||
$this->authorized = self::NOT_LOGGED_IN;
|
$this->authorized = self::NOT_LOGGED_IN;
|
||||||
$this->authorization = null;
|
$this->authorization = null;
|
||||||
|
|
||||||
Loop::defer(function () use ($datacenter, &$request, &$response) {
|
$this->call((function () use ($datacenter, &$request, &$response) {
|
||||||
$this->call((function () use ($datacenter, &$request, &$response) {
|
yield $this->init_authorization_async();
|
||||||
yield $this->init_authorization_async();
|
|
||||||
|
|
||||||
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
$this->handle_reject($datacenter, $request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code']));
|
||||||
})());
|
})());
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Loop::defer(function () use ($request_id, $datacenter) {
|
$this->call((function () use ($request_id, $datacenter) {
|
||||||
$this->call((function () use ($request_id, $datacenter) {
|
yield $this->init_authorization_async();
|
||||||
yield $this->init_authorization_async();
|
|
||||||
|
|
||||||
$this->method_recall('', ['message_id' => $request_id, 'datacenter' => $datacenter]);
|
$this->method_recall('', ['message_id' => $request_id, 'datacenter' => $datacenter]);
|
||||||
})());
|
})());
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
case 'AUTH_KEY_PERM_EMPTY':
|
case 'AUTH_KEY_PERM_EMPTY':
|
||||||
$this->logger->logger('Temporary auth key not bound, resetting temporary auth key...', \danog\MadelineProto\Logger::ERROR);
|
$this->logger->logger('Temporary auth key not bound, resetting temporary auth key...', \danog\MadelineProto\Logger::ERROR);
|
||||||
|
|
||||||
$this->datacenter->sockets[$datacenter]->temp_auth_key = null;
|
$this->datacenter->sockets[$datacenter]->temp_auth_key = null;
|
||||||
Loop::defer(function () use ($request_id, $datacenter) {
|
$this->call((function () use ($request_id, $datacenter) {
|
||||||
$this->call((function () use ($request_id, $datacenter) {
|
yield $this->init_authorization_async();
|
||||||
yield $this->init_authorization_async();
|
$this->method_recall('', ['message_id' => $request_id, 'datacenter' => $datacenter]);
|
||||||
$this->method_recall('', ['message_id' => $request_id, 'datacenter' => $datacenter]);
|
})());
|
||||||
})());
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -528,13 +517,10 @@ trait ResponseHandler
|
|||||||
$this->logger->logger('Set time delta to '.$this->datacenter->sockets[$datacenter]->time_delta, \danog\MadelineProto\Logger::WARNING);
|
$this->logger->logger('Set time delta to '.$this->datacenter->sockets[$datacenter]->time_delta, \danog\MadelineProto\Logger::WARNING);
|
||||||
$this->reset_session();
|
$this->reset_session();
|
||||||
$this->datacenter->sockets[$datacenter]->temp_auth_key = null;
|
$this->datacenter->sockets[$datacenter]->temp_auth_key = null;
|
||||||
Loop::defer(function () use ($request_id, $datacenter) {
|
$this->call((function () use ($datacenter, $request_id) {
|
||||||
|
yield $this->init_authorization_async();
|
||||||
$this->call((function () use ($datacenter, $request_id) {
|
$this->method_recall('', ['message_id' => $request_id, 'datacenter' => $datacenter]);
|
||||||
yield $this->init_authorization_async();
|
})());
|
||||||
$this->method_recall('', ['message_id' => $request_id, 'datacenter' => $datacenter]);
|
|
||||||
})());
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -557,19 +543,17 @@ trait ResponseHandler
|
|||||||
$botAPI = isset($request['botAPI']) && $request['botAPI'];
|
$botAPI = isset($request['botAPI']) && $request['botAPI'];
|
||||||
unset($request);
|
unset($request);
|
||||||
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
$this->got_response_for_outgoing_message_id($request_id, $datacenter);
|
||||||
Loop::defer(function () use ($request_id, $response, $datacenter, $botAPI) {
|
$this->call((
|
||||||
$this->call((
|
function () use ($request_id, $response, $datacenter, $botAPI) {
|
||||||
function () use ($request_id, $response, $datacenter, $botAPI) {
|
$r = isset($response['_']) ? $response['_'] : json_encode($response);
|
||||||
$r = isset($response['_']) ? $response['_'] : json_encode($response);
|
$this->logger->logger("Deferred: sent $r to deferred");
|
||||||
$this->logger->logger("Deferred: sent $r to deferred");
|
if ($botAPI) {
|
||||||
if ($botAPI) {
|
$response = yield $this->MTProto_to_botAPI_async($response);
|
||||||
$response = yield $this->MTProto_to_botAPI_async($response);
|
|
||||||
}
|
|
||||||
$this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise']->resolve($response);
|
|
||||||
unset($this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise']);
|
|
||||||
}
|
}
|
||||||
)());
|
$this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise']->resolve($response);
|
||||||
});
|
unset($this->datacenter->sockets[$datacenter]->outgoing_messages[$request_id]['promise']);
|
||||||
|
}
|
||||||
|
)());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handle_pending_updates_async()
|
public function handle_pending_updates_async()
|
||||||
|
Loading…
Reference in New Issue
Block a user