diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 4d1dd5926..e66efc880 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -669,15 +669,15 @@ class MTProto extends \Volatile 'layer' => $this->settings['tl_schema']['layer'], 'query' => $this->serialize_method('initConnection', [ - 'api_id' => $this->settings['app_info']['api_id'], - 'api_hash' => $this->settings['app_info']['api_hash'], - 'device_model' => strpos($options['datacenter'], 'cdn') === false ? $this->settings['app_info']['device_model'] : 'n/a', - 'system_version' => strpos($options['datacenter'], 'cdn') === false ? $this->settings['app_info']['system_version'] : 'n/a', - 'app_version' => $this->settings['app_info']['app_version'], + 'api_id' => $this->settings['app_info']['api_id'], + 'api_hash' => $this->settings['app_info']['api_hash'], + 'device_model' => strpos($options['datacenter'], 'cdn') === false ? $this->settings['app_info']['device_model'] : 'n/a', + 'system_version' => strpos($options['datacenter'], 'cdn') === false ? $this->settings['app_info']['system_version'] : 'n/a', + 'app_version' => $this->settings['app_info']['app_version'], 'system_lang_code' => $this->settings['app_info']['lang_code'], - 'lang_code' => $this->settings['app_info']['lang_code'], - 'lang_pack' => '', - 'query' => $this->serialize_method($method, $arguments), + 'lang_code' => $this->settings['app_info']['lang_code'], + 'lang_pack' => '', + 'query' => $this->serialize_method($method, $arguments), ] ), ], diff --git a/tests/testing.php b/tests/testing.php index 08653afd4..c55138b21 100755 --- a/tests/testing.php +++ b/tests/testing.php @@ -73,8 +73,8 @@ $message = (getenv('TRAVIS_COMMIT') == '') ? 'I iz works always (io laborare sem 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', [ + $start = false; + var_dump($id = $MadelineProto->request_call('@danogentili', [ 'set_state' => function ($state) { var_dump("SET STATE $state"); }, @@ -106,31 +106,32 @@ var_dump($id = $MadelineProto->request_call('@danogentili', [ ], ])); -while (!$start) $MadelineProto->get_updates(); - $controller = $MadelineProto->get_call($id)['controller']; - $samplerate = 48000; - $period = 1 / $samplerate; - $writePeriod = $period * 960; - var_dump($writePeriod); - var_dump('SENDING DATA'); - $f = fopen('output.raw', 'r'); - $time = microtime(true); - while (!feof($f)) { - var_dump($t = (int) (($writePeriod - + while (!$start) { + $MadelineProto->get_updates(); + } + $controller = $MadelineProto->get_call($id)['controller']; + $samplerate = 48000; + $period = 1 / $samplerate; + $writePeriod = $period * 960; + var_dump($writePeriod); + var_dump('SENDING DATA'); + $f = fopen('output.raw', 'r'); + $time = microtime(true); + while (!feof($f)) { + var_dump($t = (int) (($writePeriod - (microtime(true) - $time) // Time it took me to write frames ) * 1000000)); - usleep( + usleep( $t ); - $time = microtime(true); - var_dump($controller->writeFrames(stream_get_contents($f, 960 * 2))); - var_dump('sent 960 frames'); - } + $time = microtime(true); + var_dump($controller->writeFrames(stream_get_contents($f, 960 * 2))); + var_dump('sent 960 frames'); + } - -while ($MadelineProto->call_status($id) !== \danog\MadelineProto\MTProto::READY) { - $MadelineProto->get_updates(); -} + while ($MadelineProto->call_status($id) !== \danog\MadelineProto\MTProto::READY) { + $MadelineProto->get_updates(); + } var_dump(getenv('TEST_SECRET_CHAT')); $secret = $MadelineProto->API->request_secret_chat(getenv('TEST_SECRET_CHAT')); @@ -199,7 +200,6 @@ $mention = $MadelineProto->get_info(getenv('TEST_USERNAME')); // Returns an arra $mention = $mention['user_id']; // Selects only the numeric user id $media = []; - // Sticker $inputFile = $MadelineProto->upload('tests/lel.webp'); $media['sticker'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/lel.webp'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeSticker', 'alt' => 'LEL', 'stickerset' => ['_' => 'inputStickerSetEmpty']]]];