Login   Register  
PHP Classes

File: examples/case-studies/system/communication/threaded_notification_dispatcher-GR.md

Recommend this page to a friend!
  Classes of ASCOOS CMS   Ascoos OS   examples/case-studies/system/communication/threaded_notification_dispatcher-GR.md   Download  
File: examples/case-studies/system/communication/threaded_notification_dispatcher-GR.md
Role: Auxiliary data
Content typex: text/markdown
Description: Auxiliary data
Class: Ascoos OS
A PHP Web 5.0 Kernel for decentralized web and IoT
Author: By
Last change: Update of examples/case-studies/system/communication/threaded_notification_dispatcher-GR.md
Date: 1 month ago
Size: 3,738 bytes
 

Contents

Class file image Download

?????????? ???????????? ?? ??????

???? ? ?????? ?????????? ??????????? ??? ?? Ascoos OS ?????? ?? ?????????????? ??? ??? ???????? ???????????? ?? ?????????? ?????????? ?????????? ???? ??????? ??? ??? Telegram API. ???????????? ????????? ????????, ??????????? ??? ???????? ??????????.

??????

?? ?????????? ????????? ??? ???????? ??????? ??? Ascoos OS: - TThreadHandler: ??????? ????????? ???????? ??????????. - TTelegramAPIHandler: ??????? ???????? ???? ??? Telegram Bot API. - TObserverHandler: ???????????? ??? ?????????? ???????? ????????? ???? ???????????.

????

? ?????? ??????????? ?? ??? ?????? PHP: - threaded_notification_dispatcher.php: ???????????? ?????? ????????? ?? ??????, ?????????? Telegram ??? ????????????? ?????????.

??????????????

  1. ??????????? ??? Ascoos OS (????? repository).
  2. ?????????? Telegram bot ??? ???? `bot_token`.
  3. ?????????? ???????? ???? ?????? `$AOS_LOGS_PATH`.
  4. ? ?????????? phpBCL8 ????? ???????????????? ??? ?????????? ????????.

??????????

  1. ?????????????? ?? `your_bot_token` ??? `your_chat_id` ?? ??????????? ?????.
  2. ????????? ?? script ???? web server: https://localhost/aos/examples/case-studies/system/communication/threaded_notification_dispatcher.php 

?????????? ??????

$observerHandler = TObserverHandler::getInstance([$properties['logs']]); $observerHandler->attach(new SystemObserver(), 10); $threadHandler->startThread('task_chat_id'.$chat_id, function () use (...) { $telegram = new TTelegramAPIHandler(...); $telegram->sendMessage(['chat_id' => $chat_id, 'text' => $message]); $observerHandler->notify(['event' => 'telegram.sent', 'data' => ['chat_id' => $chat_id]]); }); 

??????????? ??????????

?? script ??????? ?????? ?? ???? ????????? ??? ?????????? ???????? ? ????????. ?????????? log:

System event observed: {"event":"telegram.sent","data":{"chat_id":"123456789"}} System event observed: {"event":"telegram.failed","data":{"chat_id":"987654321"}} 

?????

??????????

?????? ?? ???????????? ?? ???? ?? ?????? ??????????; ????? fork ?? ??????????, ???????????? ? ????????? ???? ??????????? ??? threaded_notification_dispatcher.php, ??? ????????? pull request. ????? ?? CONTRIBUTING.md ??? ???????.

????? ??????

???? ? ?????? ?????????? ?????????? ??? ??? Ascoos General License (AGL). ????? ?? LICENSE.