Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Nov 29, 2023
1 parent 693ce6b commit 67639ed
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/Channels/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Laravel\Reverb\Contracts\ChannelConnectionManager;
use Laravel\Reverb\Contracts\Connection;
use React\EventLoop\Loop;
use Spatie\Fork\Fork;

class Channel
Expand Down Expand Up @@ -107,18 +108,29 @@ public function broadcastToAll(array $payload): void

$chunks = array_chunk($this->connections(), 5000);

$forks = array_map(function ($connections) use ($message) {
return function () use ($connections, $message) {
$loop = Loop::get();

foreach ($chunks as $connections) {
$loop->futureTick(function () use ($connections, $message) {
foreach ($connections as $connection) {
dump('Sending');
$connection->send($message);
}
};
}, $chunks);
});
}

// $forks = array_map(function ($connections) use ($message) {
// return function () use ($connections, $message) {
// foreach ($connections as $connection) {
// dump('Sending');
// $connection->send($message);
// }
// };
// }, $chunks);

dump($forks);
// dump($forks);

(new Fork)->run(...$forks);
// (new Fork)->run(...$forks);
}

/**
Expand Down

0 comments on commit 67639ed

Please sign in to comment.