Skip to content

use app default event loop for websocket calls #390

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

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 ✅

📢 Thoughts on this report? Let us know!

@stale stale bot added the wontfix This will not be worked on label Mar 17, 2024
Copy link

stale bot commented Apr 26, 2025

This issue has been automatically closed because it has not had any recent activity. 😨

@stale stale bot closed this Apr 26, 2025
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