1.hhxsv5/laravel-s适配器github地址:
https://github.com/hhxsv5/laravel-s
2.主要代码
/**@var \Swoole\Http\Server|\Swoole\WebSocket\Server $swoole */
$swoole = app('swoole');
// $swoole->ports:遍历所有Port对象,https://wiki.swoole.com/#/server/properties?id=ports
$port = $swoole->ports[1]; // 获得`Swoole\Server\Port`对象,$port[0]是主服务器的端口
foreach ($port->connections as $fd) { // 遍历所有连接
// $swoole->send($fd, 'Send tcp message');
// if($swoole->isEstablished($fd)) {
// $swoole->push($fd, 'Send websocket message');
// }
}
3.说明