This repository was archived by the owner on Sep 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +22
-20
lines changed Expand file tree Collapse file tree 1 file changed +22
-20
lines changed Original file line number Diff line number Diff line change 2121$ sendChatAction ->chat_id = A_USER_CHAT_ID ;
2222$ sendChatAction ->action = 'typing ' ;
2323
24- $ tgLog ->performApiRequest ($ sendChatAction );
25- // Some heavy operation you have to perform, in our case, it will 2 seconds
26- sleep (2 );
27-
28- $ sendMessage ->text = 'The second piece of text ' ;
29-
30- $ promise = $ tgLog ->performApiRequest ($ sendMessage );
31-
32- $ promise ->then (
33- function ($ response ) {
34- echo '2nd message sent ' . PHP_EOL ;
35- echo '<pre> ' ;
36- var_dump ($ response );
37- echo '</pre> ' ;
38- },
39- function (\Exception $ exception ) {
40- // Onoes, an exception occurred...
41- echo 'Exception ' . get_class ($ exception ) . ' caught, message: ' . $ exception ->getMessage ();
42- }
43- );
24+ $ promise = $ tgLog ->performApiRequest ($ sendChatAction );
25+
26+ $ promise ->then (function () use ($ tgLog , $ sendMessage ) {
27+ sleep (3 );
28+
29+ $ sendMessage ->text = 'The second piece of text ' ;
30+
31+ $ promise = $ tgLog ->performApiRequest ($ sendMessage );
32+
33+ $ promise ->then (
34+ function ($ response ) {
35+ echo '2nd message sent ' . PHP_EOL ;
36+ echo '<pre> ' ;
37+ var_dump ($ response );
38+ echo '</pre> ' ;
39+ },
40+ function (\Exception $ exception ) {
41+ // Onoes, an exception occurred...
42+ echo 'Exception ' . get_class ($ exception ) . ' caught, message: ' . $ exception ->getMessage ();
43+ }
44+ );
45+ });
4446
4547$ loop ->run ();
You can’t perform that action at this time.
0 commit comments