Implemented writeAll and closeAll for groups

This commit is contained in:
2024-02-22 01:32:31 +01:00
parent b0aede55b9
commit ca84671f33
4 changed files with 31 additions and 2 deletions

View File

@ -61,8 +61,20 @@ class ConnectionGroup implements EventEmitterInterface, IteratorAggregate, Count
return $this->name;
}
public function write(string $payload)
public function writeAll(string $payload)
{
foreach ($this->connections as $connection) {
if ($connection->isWritable()) {
$connection->write($payload);
}
}
}
public function closeAll(string $reason, int $code=1001)
{
foreach ($this->connections as $connection) {
$connection->closeWithReason($reason, $code);
}
}
}