Use http_wait instead of ping to wakeup closed sockets, add debugging phar creation script

This commit is contained in:
Daniil Gentili 2018-02-26 02:30:22 +00:00
parent d5fe532e22
commit bbe24e70d9
2 changed files with 42 additions and 1 deletions

View File

@ -72,7 +72,11 @@ trait MessageHandler
{
if ($this->datacenter->sockets[$datacenter]->must_open) {
\danog\MadelineProto\Logger::log(['Trying to read from closed socket, sending initial ping']);
$this->method_call('ping', ['ping_id' => 0], ['datacenter' => $datacenter]);
if ($this->is_http($datacenter)) {
$this->method_call('http_wait', ['max_wait' => 500, 'wait_after' => 150, 'max_delay' => 500], ['datacenter' => $datacenter]);
} else {
$this->method_call('ping', ['ping_id' => 0], ['datacenter' => $datacenter]);
}
}
$payload = $this->datacenter->sockets[$datacenter]->read_message();
if (strlen($payload) === 4) {

37
tests/makephardebug.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash -e
composer global require spatie/7to5
[ -f $HOME/.composer/vendor/bin/php7to5 ] && php7to5=$HOME/.composer/vendor/bin/php7to5
[ -f $HOME/.config/composer/vendor/bin/php7to5 ] && php7to5=$HOME/.config/composer/vendor/bin/php7to5
rm -rf phar7 phar5 MadelineProtoPhar
mkdir phar7
cd phar7
echo '{
"name": "danog/madelineprototests",
"minimum-stability":"dev",
"require": {
"danog/madelineproto": "dev-master"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/danog/phpseclib"
}
],
"authors": [
{
"name": "Daniil Gentili",
"email": "daniil@daniil.it"
}
]
}' > composer.json
composer update
cp -a ../src vendor/danog/madelineproto
cd ..
$php7to5 convert --copy-all phar7 phar5 >/dev/null
php makephar.php phar5 madeline.phar $(cat .git/refs/heads/master)