1
0
mirror of https://github.com/danog/MadelineProto.git synced 2025-01-11 14:28:17 +01:00
MadelineProto/src/EventHandler/Update.php

37 lines
797 B
PHP
Raw Normal View History

2023-06-28 15:50:38 +02:00
<?php declare(strict_types=1);
namespace danog\MadelineProto\EventHandler;
use danog\MadelineProto\Ipc\Client;
use danog\MadelineProto\MTProto;
/**
* Represents a generic update.
*/
abstract class Update
{
private readonly string $session;
protected MTProto|Client|null $API;
/** @internal */
2023-07-01 13:04:59 +02:00
public function __construct(
2023-06-28 15:50:38 +02:00
MTProto $API,
) {
$this->API = $API;
$this->session = $API->wrapper->getSession()->getSessionDirectoryPath();
}
2023-07-01 13:04:59 +02:00
/** @internal */
2023-06-28 15:50:38 +02:00
public function __sleep()
{
$vars = \get_object_vars($this);
unset($vars['API']);
return \array_keys($vars);
}
2023-07-01 13:04:59 +02:00
/** @internal */
2023-06-28 15:50:38 +02:00
public function __wakeup(): void
{
$this->API = Client::giveInstanceBySession($this->session);
}
}