1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 00:34:40 +01:00

Fixes to lua

This commit is contained in:
Daniil Gentili 2017-07-01 19:39:35 +02:00
parent cf9fd67eda
commit 54e7499930
3 changed files with 36 additions and 37 deletions

View File

@ -47,6 +47,9 @@ class Lua
}
$methods = [];
foreach ($this->MadelineProto->get_methods_namespaced() as $method => $namespace) {
if ($namespace === 'upload') {
continue;
}
$methods[$namespace][$method] = [$this->MadelineProto->{$namespace}, $method];
}
foreach ($this->MadelineProto->get_method_namespaces() as $namespace) {

View File

@ -22,7 +22,7 @@ trait AuthKeyHandler
{
private $calls = [];
public function request_call($user, $callbacks)
public function request_call($user, $class)
{
$user = $this->get_info($user);
if (!isset($user['InputUser'])) {
@ -38,7 +38,7 @@ trait AuthKeyHandler
$this->check_G($g_a, $dh_config['p']);
$res = $this->method_call('phone.requestCall', ['user_id' => $user, 'g_a_hash' => hash('sha256', $g_a->toBytes(), true), 'protocol' => ['_' => 'phoneCallProtocol', 'udp_p2p' => true, 'min_layer' => 65, 'max_layer' => 65]], ['datacenter' => $this->datacenter->curdc]);
$this->calls[$res['phone_call']['id']] = ['status' => self::REQUESTED, 'a' => $a, 'g_a' => $g_a, 'callbacks' => $callbacks];
$this->calls[$res['phone_call']['id']] = ['status' => self::REQUESTED, 'a' => $a, 'g_a' => $g_a, 'class' => $class];
$this->handle_pending_updates();
$this->get_updates_difference();
@ -85,9 +85,8 @@ trait AuthKeyHandler
foreach (str_split(strrev(substr(hash('sha256', $this->calls[$params['id']]['g_a']->toBytes().$key['auth_key'], true), 20)), 8) as $number) {
$key['visualization'] .= self::EMOJIS[(int) ((new \phpseclib\Math\BigInteger($number, -256))->divide($length)[1]->toString())];
}
$this->calls[$params['id']] = ['status' => self::READY, 'key' => $key, 'admin' => true, 'user_id' => $params['participant_id'], 'InputPhoneCall' => ['id' => $params['id'], 'access_hash' => $params['access_hash'], '_' => 'inputPhoneCall'], 'in_seq_no_x' => 0, 'out_seq_no_x' => 1, 'layer' => 65, 'updated' => time(), 'incoming' => [], 'outgoing' => [], 'created' => time(), 'protocol' => $params['protocol'], 'callbacks' => $this->calls[$params['id']]['callbacks']];
$this->calls[$params['id']]['controller'] = new \danog\MadelineProto\VoIP($this->calls[$params['id']]['callbacks']['set_state'], $this->calls[$params['id']]['callbacks']['incoming'], $this->calls[$params['id']]['callbacks']['outgoing'], $this, $this->calls[$params['id']]['InputPhoneCall']);
var_dump($this->calls[$params['id']]['class']);
$this->calls[$params['id']] = ['status' => self::READY, 'key' => $key, 'admin' => true, 'user_id' => $params['participant_id'], 'InputPhoneCall' => ['id' => $params['id'], 'access_hash' => $params['access_hash'], '_' => 'inputPhoneCall'], 'in_seq_no_x' => 0, 'out_seq_no_x' => 1, 'layer' => 65, 'updated' => time(), 'incoming' => [], 'outgoing' => [], 'created' => time(), 'protocol' => $params['protocol'], 'controller' => new $this->calls[$params['id']]['class']($this, $params['id'])];
$this->calls[$params['id']]['controller']->setConfig($this->config['call_receive_timeout_ms'] / 1000, $this->config['call_connect_timeout_ms'] / 1000, \danog\MadelineProto\VoIP::DATA_SAVING_NEVER, true, true, true, $this->settings['calls']['log_file_path'], $this->settings['calls']['stats_dump_file_path']);
$this->calls[$params['id']]['controller']->setEncryptionKey($key['auth_key'], true);
$this->calls[$params['id']]['controller']->setNetworkType($this->settings['calls']['network_type']);

View File

@ -69,43 +69,40 @@ if ($MadelineProto === false) {
}
}
$message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sembre) (yo lavorar siempre) (mi labori ĉiam) (я всегда работать) (Ik werkuh altijd) (Ngimbonga ngaso sonke isikhathi ukusebenza)' : ('Travis ci tests in progress: commit '.getenv('TRAVIS_COMMIT').', job '.getenv('TRAVIS_JOB_NUMBER').', PHP version: '.getenv('TRAVIS_PHP_VERSION'));
class pony extends \danog\MadelineProto\VoIP
{
public function setState(int $state) {
var_dump("SET STATE $state");
}
public function startOutput() {
var_dump("START READING DATA");
}
public function startInput() {
var_dump("START WRITING DATA");
}
public function stopOutput() {
var_dump("STOP READING DATA");
}
public function stopInput() {
var_dump("STOP WRITING DATA");
}
public function configureAudioOutput(int $sampleRate, int $bitsPerSample, int $channels) {
var_dump("CONFIGURE AUDIO OUTPUT: sampleRate: $sampleRate, bitsPerSample: $bitsPerSample, channels: $channels");
}
public function configureAudioInput(int $sampleRate, int $bitsPerSample, int $channels) {
var_dump("CONFIGURE AUDIO INPUT: sampleRate: $sampleRate, bitsPerSample: $bitsPerSample, channels: $channels");
}
public function getOutputLevel() {
return 0;
}
}
echo 'Serializing MadelineProto to session.madeline...'.PHP_EOL; echo 'Wrote
'.\danog\MadelineProto\Serialization::serialize('session.madeline', $MadelineProto).' bytes'.PHP_EOL;
if (stripos(readline('Do you want to make the secret chat tests? (y/n): '), 'y') !== false) {
$start = false;
var_dump($id = $MadelineProto->request_call('@danogentili', [
'set_state' => function ($state) {
var_dump("SET STATE $state");
},
'incoming' => [
'start' => function () {
var_dump('PLEASE START RECEIVING DATA');
},
'stop' => function () {
var_dump('PLEASE STOP RECEIVING DATA');
},
'configure' => function ($sampleRate, $bitsPerSample, $channels) {
var_dump("incoming sampleRate: $sampleRate, bitsPerSample: $bitsPerSample, channels: $channels");
},
],
'outgoing' => [
'start' => function () use (&$start) {
var_dump('PLEASE START SENDING DATA');
$start = true;
},
'stop' => function () {
var_dump('PLEASE STOP SENDING DATA');
},
'configure' => function ($sampleRate, $bitsPerSample, $channels) {
var_dump("outgoing sampleRate: $sampleRate, bitsPerSample: $bitsPerSample, channels: $channels");
},
'get_level' => function () {
return 1;
},
],
]));
var_dump($id = $MadelineProto->request_call('@magnaluna', '\pony'));
while (!$start) {
$MadelineProto->get_updates();
}