Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use app default event loop for websocket calls #390

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

petli-full
Copy link

For websocket calls, instead of creating a new event loop, it's better using the default one. This allows other IO events can be attached to the same event loop and act on each other accordingly. For example (pseudo code),

// signal a pod by another IO event
$conn = null;

$pod->attach(function (WebSocket $connection) use (&$conn) {
    $conn = $connection;
    ......
});

$loop->addTimer(0.8, function () use (&$conn) {
    if ($conn) $conn->send('0123456789');
});

Besides, it is recommended by ReactPHP. The create method has been deprecated: https://github.com/reactphp/event-loop/blob/1.x/src/Factory.php#L13-L34

@codecov
Copy link

codecov bot commented Oct 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.17%. Comparing base (046c682) to head (fcbe038).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #390   +/-   ##
=========================================
  Coverage     94.17%   94.17%           
  Complexity      700      700           
=========================================
  Files            70       70           
  Lines          1837     1837           
=========================================
  Hits           1730     1730           
  Misses          107      107           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stale stale bot added the wontfix This will not be worked on label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant