diff --git a/server.php b/server.php index 531c9fd0..da1c1c48 100644 --- a/server.php +++ b/server.php @@ -4,4 +4,3 @@ require 'vendor/autoload.php'; $handler = new \danog\MadelineProto\Server(['type' => AF_INET, 'protocol' => 0, 'address' => 'localhost', 'port' => 8011]); $handler->start(); - diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index 627b86b3..ecc0d4e1 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -170,10 +170,14 @@ class API extends APIFactory $this->API->wrapper = $this; } } + public function get_all_methods() { $methods = []; - foreach ($this->API->methods->by_id as $method) { $methods []= $method['method']; } + foreach ($this->API->methods->by_id as $method) { + $methods[] = $method['method']; + } + return array_merge($methods, get_class_methods($this->API)); } diff --git a/src/danog/MadelineProto/Server/Handler.php b/src/danog/MadelineProto/Server/Handler.php index e6319f75..8459f7ae 100644 --- a/src/danog/MadelineProto/Server/Handler.php +++ b/src/danog/MadelineProto/Server/Handler.php @@ -101,9 +101,12 @@ class Handler extends \danog\MadelineProto\Connection $message = $this->read_message(); } } catch (\danog\MadelineProto\NothingInTheSocketException $e) { - if (time() - $time < 2) $this->sock = null; + if (time() - $time < 2) { + $this->sock = null; + } continue; } + try { $message = $this->deserialize($message, ['type' => '', 'datacenter' => '']); if ($message['_'] !== 'socketMessageRequest') { @@ -158,14 +161,17 @@ class Handler extends \danog\MadelineProto\Connection $arg['file'] = fopen('madelineSocket://', 'r+b', false, Stream::getContext($zis, $arg['file']['stream_id'])); } $arg = new \danog\MadelineProto\FileCallback($arg['file'], [$zis, $arg['callback']['callback']]); + return; } if ($arg['_'] === 'callback' && isset($arg['callback']) && !method_exists($zis, $arg['callback'])) { $arg = [$zis, $arg['callback']]; + return; } if ($arg['_'] === 'stream' && isset($arg['stream_id'])) { $arg = fopen('madelineSocket://', 'r+b', false, Stream::getContext($zis, $arg['stream_id'])); + return; } }