mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-26 20:04:45 +01:00
websocket client example update
This commit is contained in:
parent
a8997ed469
commit
39a269b207
@ -77,8 +77,8 @@ Fast, simple, async php telegram api server:
|
||||
* EventHandler updates via websocket. Connect to `ws://127.0.0.1:9503/events`. You will get all events in json.
|
||||
Each event stored inside object, where key is name of session which created event.
|
||||
|
||||
When using CombinedAPI (multiple account) name of session can be added to path of websocket endpoint.
|
||||
`ws://127.0.0.1:9503/events/session_name`. This endpoint will emmit events only from given session.
|
||||
When using CombinedAPI (multiple account) name of session can be added to path of websocket endpoint:
|
||||
`ws://127.0.0.1:9503/events/session_name`. This endpoint will send events only from given session.
|
||||
|
||||
PHP websocket client example: [websocket-events.php](https://github.com/xtrime-ru/TelegramApiServer/blob/master/examples/websocket-events.php)
|
||||
|
||||
|
@ -26,6 +26,10 @@ Amp\Loop::run(function () use($options) {
|
||||
/** @var Connection $connection */
|
||||
$connection = yield connect($options['url']);
|
||||
|
||||
$connection->onClose(static function() use($connection) {
|
||||
printf("Connection closed. Reason: %s\n", $connection->getCloseReason());
|
||||
});
|
||||
|
||||
echo 'Waiting for events...' . PHP_EOL;
|
||||
while ($message = yield $connection->receive()) {
|
||||
/** @var Message $message */
|
||||
|
Loading…
Reference in New Issue
Block a user