Files
kiri-core/HttpServer/Emit.php
T

41 lines
551 B
PHP
Raw Normal View History

2021-04-12 15:16:47 +08:00
<?php
namespace HttpServer;
use Exception;
use Snowflake\Abstracts\Component;
use Snowflake\Snowflake;
/**
* Class Emit
* @package HttpServer
*/
class Emit extends Component
{
private array $_array = [];
/**
2021-04-12 15:37:13 +08:00
* @param int[] $users
2021-04-12 15:16:47 +08:00
* @param string $message
* @throws Exception
*/
2021-04-12 15:37:13 +08:00
public function emit(array $users, string $message)
2021-04-12 15:16:47 +08:00
{
2021-04-12 15:37:13 +08:00
$table = Snowflake::app()->getTable('SYSTEM:ONLINE:PEOPLES');
2021-04-12 15:16:47 +08:00
2021-04-12 15:37:13 +08:00
foreach ($users as $user) {
$fd = $table->get((string)$user, ['clientId']);
2021-04-12 15:16:47 +08:00
2021-04-12 15:37:13 +08:00
Snowflake::push($fd, $message);
2021-04-12 15:16:47 +08:00
}
2021-04-12 15:37:13 +08:00
2021-04-12 15:16:47 +08:00
}
}