Bugfixes in response management

This commit is contained in:
Daniil Gentili 2020-01-05 17:29:36 +00:00
parent dd6803e4d7
commit ea197a115f
5 changed files with 15 additions and 13 deletions

View File

@ -25,7 +25,7 @@
"ext-fileinfo": "*", "ext-fileinfo": "*",
"amphp/amp": "^2.0", "amphp/amp": "^2.0",
"amphp/websocket-client": "dev-master as 1.0.0-rc2", "amphp/websocket-client": "dev-master as 1.0.0-rc2",
"amphp/http-client": "^4", "amphp/http-client": "dev-master as 4",
"amphp/socket": "^1", "amphp/socket": "^1",
"amphp/dns": "^1", "amphp/dns": "^1",
"amphp/file": "^1", "amphp/file": "^1",

2
docs

@ -1 +1 @@
Subproject commit 67daced51adb23487f77f5526a4ae9e0dbc841b5 Subproject commit 4ed3a8447cf21c69322bcdaf149eb3ce0befe8c0

View File

@ -46,6 +46,10 @@ trait AckHandler
public function gotResponseForOutgoingMessageId($message_id): bool public function gotResponseForOutgoingMessageId($message_id): bool
{ {
// The server acknowledges that it received my message // The server acknowledges that it received my message
if (isset($this->new_outgoing[$message_id])) {
unset($this->new_outgoing[$message_id]);
}
if (!isset($this->outgoing_messages[$message_id])) { if (!isset($this->outgoing_messages[$message_id])) {
$this->logger->logger("WARNING: Couldn't find message id ".$message_id.' in the array of outgoing messages. Maybe try to increase its size?', \danog\MadelineProto\Logger::WARNING); $this->logger->logger("WARNING: Couldn't find message id ".$message_id.' in the array of outgoing messages. Maybe try to increase its size?', \danog\MadelineProto\Logger::WARNING);
@ -57,9 +61,6 @@ trait AckHandler
if (isset($this->outgoing_messages[$message_id]['serialized_body'])) { if (isset($this->outgoing_messages[$message_id]['serialized_body'])) {
unset($this->outgoing_messages[$message_id]['serialized_body']); unset($this->outgoing_messages[$message_id]['serialized_body']);
} }
if (isset($this->new_outgoing[$message_id])) {
unset($this->new_outgoing[$message_id]);
}
return true; return true;
} }

View File

@ -398,7 +398,7 @@ trait ResponseHandler
} }
$this->gotResponseForOutgoingMessageId($request_id); $this->gotResponseForOutgoingMessageId($request_id);
$this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : '')); $this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], $request['_'] ?? ''));
return; return;
case 303: case 303:
@ -445,7 +445,7 @@ trait ResponseHandler
\danog\MadelineProto\Tools::callFork((function () use (&$request, &$response) { \danog\MadelineProto\Tools::callFork((function () use (&$request, &$response) {
yield $this->API->initAuthorization(); yield $this->API->initAuthorization();
$this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : '')); $this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], $request['_'] ?? ''));
})()); })());
return; return;
@ -457,7 +457,7 @@ trait ResponseHandler
\danog\MadelineProto\Tools::callFork((function () use (&$request, &$response) { \danog\MadelineProto\Tools::callFork((function () use (&$request, &$response) {
yield $this->API->initAuthorization(); yield $this->API->initAuthorization();
$this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : '')); $this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], $request['_'] ?? ''));
})()); })());
return; return;
@ -490,7 +490,7 @@ trait ResponseHandler
\danog\MadelineProto\Tools::callFork((function () use (&$request, &$response) { \danog\MadelineProto\Tools::callFork((function () use (&$request, &$response) {
yield $this->API->initAuthorization(); yield $this->API->initAuthorization();
$this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : '')); $this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], $request['_'] ?? ''));
})()); })());
return; return;
@ -515,7 +515,7 @@ trait ResponseHandler
} }
$this->gotResponseForOutgoingMessageId($request_id); $this->gotResponseForOutgoingMessageId($request_id);
$this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : '')); $this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], $request['_'] ?? ''));
return; return;
case 420: case 420:
@ -534,7 +534,7 @@ trait ResponseHandler
default: default:
$this->gotResponseForOutgoingMessageId($request_id); $this->gotResponseForOutgoingMessageId($request_id);
$this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], isset($request['_']) ? $request['_'] : '')); $this->handleReject($request, new \danog\MadelineProto\RPCErrorException($response['error_message'], $response['error_code'], $request['_'] ?? ''));
return; return;
} }
@ -567,7 +567,7 @@ trait ResponseHandler
return; return;
} }
$this->gotResponseForOutgoingMessageId($request_id); $this->gotResponseForOutgoingMessageId($request_id);
$this->handleReject($request, new \danog\MadelineProto\RPCErrorException('Received bad_msg_notification: '.MTProto::BAD_MSG_ERROR_CODES[$response['error_code']], $response['error_code'], isset($request['_']) ? $request['_'] : '')); $this->handleReject($request, new \danog\MadelineProto\RPCErrorException('Received bad_msg_notification: '.MTProto::BAD_MSG_ERROR_CODES[$response['error_code']], $response['error_code'], $request['_'] ?? ''));
return; return;
} }
@ -578,6 +578,7 @@ trait ResponseHandler
} }
if (!isset($request['promise'])) { if (!isset($request['promise'])) {
$this->gotResponseForOutgoingMessageId($request_id);
$this->logger->logger('Response: already got response for '.(isset($request['_']) ? $request['_'] : '-').' with message ID '.$request_id); $this->logger->logger('Response: already got response for '.(isset($request['_']) ? $request['_'] : '-').' with message ID '.$request_id);
return; return;

View File

@ -987,7 +987,7 @@ class TL
} }
if ($constructorData['type'] === 'Vector t') { if ($constructorData['type'] === 'Vector t') {
$constructorData['connection'] = $type['connection']; $constructorData['connection'] = $type['connection'];
$constructorData['subtype'] = isset($type['subtype']) ? $type['subtype'] : ''; $constructorData['subtype'] = $type['subtype'] ?? '';
$constructorData['type'] = 'vector'; $constructorData['type'] = 'vector';
return $this->deserialize($stream, $constructorData); return $this->deserialize($stream, $constructorData);