mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 00:34:40 +01:00
Final fixes
This commit is contained in:
parent
fe3fa04361
commit
4aa9578c4f
@ -711,9 +711,13 @@ class MTProto extends \Volatile
|
||||
* ***********************************************************************
|
||||
* Fetch RSA keys for CDN datacenters
|
||||
*/
|
||||
foreach ($this->method_call('help.getCdnConfig', [], ['datacenter' => $datacenter])['public_keys'] as $curkey) {
|
||||
$tempkey = new \danog\MadelineProto\RSA($curkey['public_key']);
|
||||
$this->rsa_keys[$tempkey->fp] = $tempkey;
|
||||
try {
|
||||
foreach ($this->method_call('help.getCdnConfig', [], ['datacenter' => $datacenter])['public_keys'] as $curkey) {
|
||||
$tempkey = new \danog\MadelineProto\RSA($curkey['public_key']);
|
||||
$this->rsa_keys[$tempkey->fp] = $tempkey;
|
||||
}
|
||||
} catch (\danog\MadelineProto\TL\Exception $e) {
|
||||
\danog\MadelineProto\Logger::log([$e->getMessage()], \danog\MadelineProto\Logger::FATAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,9 +468,10 @@ trait UpdateHandler
|
||||
|
||||
return;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log([$update], \danog\MadelineProto\Logger::WARNING);
|
||||
switch ($update['phone_call']['_']) {
|
||||
case 'phoneCallRequested':
|
||||
if (isset($this->calls[$update['phone_call']['id']])) return;
|
||||
|
||||
$controller = new \danog\MadelineProto\VoIP(false, $update['phone_call']['admin_id'], ['_' => 'inputPhoneCall', 'id' => $update['phone_call']['id'], 'access_hash' => $update['phone_call']['access_hash']], $this, \danog\MadelineProto\VoIP::CALL_STATE_INCOMING, $update['phone_call']['protocol']);
|
||||
$controller->storage = ['g_a_hash' => $update['phone_call']['g_a_hash']];
|
||||
$update['phone_call'] = $this->calls[$update['phone_call']['id']] = $controller;
|
||||
|
@ -48,8 +48,6 @@ trait AuthKeyHandler
|
||||
$res = $this->method_call('phone.requestCall', ['user_id' => $user, 'g_a_hash' => hash('sha256', $g_a->toBytes(), true), 'protocol' => ['_' => 'phoneCallProtocol', 'udp_p2p' => true, 'udp_reflector' => true, 'min_layer' => 65, 'max_layer' => 65]], ['datacenter' => $this->datacenter->curdc]);
|
||||
$this->calls[$res['phone_call']['id']] = $controller = new \danog\MadelineProto\VoIP(true, $user['user_id'], ['_' => 'inputPhoneCall', 'id' => $res['phone_call']['id'], 'access_hash' => $res['phone_call']['access_hash']], $this, \danog\MadelineProto\VoIP::CALL_STATE_REQUESTED, $res['phone_call']['protocol']);
|
||||
$controller->storage = ['a' => $a, 'g_a' => str_pad($g_a->toBytes(), 256, chr(0), \STR_PAD_LEFT)];
|
||||
$controller->play('../Little Swing.raw')->then('output.raw');
|
||||
$controller->setOutputFile('ou.raw');
|
||||
|
||||
$this->handle_pending_updates();
|
||||
$this->get_updates_difference();
|
||||
@ -155,13 +153,12 @@ trait AuthKeyHandler
|
||||
$controller->discard();
|
||||
}
|
||||
});
|
||||
|
||||
if ($this->call_status($params['id']) !== \danog\MadelineProto\VoIP::CALL_STATE_ACCEPTED) {
|
||||
\danog\MadelineProto\Logger::log(['Could not find and confirm call '.$params['id']]);
|
||||
\danog\MadelineProto\Logger::log(['Could not find and complete call '.$params['id']]);
|
||||
|
||||
return false;
|
||||
}
|
||||
\danog\MadelineProto\Logger::log(['Confirming call from '.$this->calls[$params['id']]->getOtherID().'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
\danog\MadelineProto\Logger::log(['Completing call from '.$this->calls[$params['id']]->getOtherID().'...'], \danog\MadelineProto\Logger::VERBOSE);
|
||||
|
||||
$dh_config = $this->get_dh_config();
|
||||
if (hash('sha256', $params['g_a_or_b'], true) != $this->calls[$params['id']]->storage['g_a_hash']) {
|
||||
@ -196,17 +193,11 @@ trait AuthKeyHandler
|
||||
'auth_key' => $key,
|
||||
'network_type' => $this->settings['calls']['network_type'],
|
||||
'shared_config' => $this->method_call('phone.getCallConfig', [], ['datacenter' => $this->datacenter->curdc]),
|
||||
'endpoints' => array_merge([$res['connection']], $res['alternative_connections']),
|
||||
'endpoints' => array_merge([$params['connection']], $params['alternative_connections']),
|
||||
], $this->calls[$params['id']]->configuration);
|
||||
$this->calls[$params['id']]->parseConfig();
|
||||
$this->calls[$params['id']]->startTheMagic();
|
||||
|
||||
while ($this->calls[$params['id']]->getState() !== \danog\MadelineProto\VoIP::STATE_ESTABLISHED);
|
||||
while ($this->calls[$params['id']]->getOutputState() === \danog\MadelineProto\VoIP::AUDIO_STATE_NONE);
|
||||
while ($this->calls[$params['id']]->getInputState() === \danog\MadelineProto\VoIP::AUDIO_STATE_NONE);
|
||||
|
||||
$this->calls[$params['id']]->play('../Little Swing.raw')->then('output.raw');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ if (stripos(readline('Do you want to handle incoming calls? (y/n): '), 'y') !==
|
||||
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
|
||||
switch ($update['update']['_']) {
|
||||
case 'updatePhoneCall':
|
||||
if ($update['update']['phone_call']->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_INCOMING) {
|
||||
if (is_object($update['update']['phone_call']) && $update['update']['phone_call']->getCallState() === \danog\MadelineProto\VoIP::CALL_STATE_INCOMING) {
|
||||
$update['update']['phone_call']->accept()->play('input.raw')->then('input.raw')->playOnHold(['input.raw'])->setOutputFile('output.raw');
|
||||
$howmany--;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user