Poller
in package
FinalYes
Long polling: the update source a bot uses when it has no public HTTPS address.
Each round calls getUpdates with a timeout, so the connection is held open
until Telegram has something to say or the timeout expires. Updates are handed
to Telegram::handleUpdate() and the offset advances past the highest
update_id seen, which is what acknowledges them. A failed round backs off
before the next one rather than hammering a server that is already unhappy.
Tags
Table of Contents
Constants
- MAX_BACKOFF : mixed = 30.0
- Longest back-off between failed rounds, in seconds.
Properties
- $allowedUpdates : ?array<string|int, mixed>
- $backoff : float
- $dropPendingUpdates : bool
- $generation : int
- Set while a round is in flight, so {@see stop()} can ignore its result.
- $limit : int
- $offset : ?int
- $running : bool
- $telegram : Telegram
- $timeout : int
Methods
- __construct() : mixed
- getOffset() : ?int
- The `update_id` the next round will ask from.
- isRunning() : bool
- start() : void
- stop() : void
- dispatch() : void
- handleFailure() : void
- poll() : void
Constants
MAX_BACKOFF
Longest back-off between failed rounds, in seconds.
private
mixed
MAX_BACKOFF
= 30.0
Properties
$allowedUpdates read-only
private
?array<string|int, mixed>
$allowedUpdates
= null
$backoff
private
float
$backoff
= 1.0
$dropPendingUpdates read-only
private
bool
$dropPendingUpdates
= false
$generation
Set while a round is in flight, so {@see stop()} can ignore its result.
private
int
$generation
= 0
$limit read-only
private
int
$limit
= 100
$offset
private
?int
$offset
= null
$running
private
bool
$running
= false
$telegram read-only
private
Telegram
$telegram
$timeout read-only
private
int
$timeout
= 50
Methods
__construct()
public
__construct(Telegram $telegram[, int $timeout = 50 ][, int $limit = 100 ][, array<int, string>|null $allowedUpdates = null ][, bool $dropPendingUpdates = false ]) : mixed
Parameters
- $telegram : Telegram
- $timeout : int = 50
- $limit : int = 100
- $allowedUpdates : array<int, string>|null = null
-
Update types to receive; null keeps Telegram's default.
- $dropPendingUpdates : bool = false
getOffset()
The `update_id` the next round will ask from.
public
getOffset() : ?int
Return values
?intisRunning()
public
isRunning() : bool
Return values
boolstart()
public
start() : void
stop()
public
stop() : void
dispatch()
private
dispatch(Collection<string|int, Update>|array<int, Update> $updates) : void
Parameters
handleFailure()
private
handleFailure(Throwable $e, int $generation) : void
Parameters
- $e : Throwable
- $generation : int
poll()
private
poll(int $generation) : void
Parameters
- $generation : int