Skip to content

Using WS message in event loop #128

@makopov

Description

@makopov

I have 3 questions here...

  1. I'm trying to figure out how to pass the message received by the WS to the event loop, see code below.
  2. Is this the right way to handle ws messages asynchronously? I notice delays with the more topics I subscribe to.
  3. My IDE is showing that React Factory is deprecated, are there plans to stop usages of it in the future?
        $loop = Factory::create();
        $loop->addPeriodicTimer(1, function($message) {
           var_dump('loop: ' . date('Y-m-d H:i:s'));
           var_dump($message);
        });
        $api->setLoop($loop);

        $api->subscribePublicChannels($query, $channels, function (array $message, WebSocket $ws, LoopInterface $loop) use(&$exchange, &$interval, &$results) {
            // $loop->run();
            // print $message['data']['symbol'] . PHP_EOL;

            }
        }, function ($code, $reason) {
            echo "OnClose: {$code} {$reason}\n";
        });

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions