+
95
-

swoole如何在http server中去操作websocket的client发送消息?

php

请问swoole如何在http server中去操作websocket的client发送消息?比如如何通过http的接口去给当前所有连接的websocket客户发送消息


网友回复

+
15
-
<?php
$server = new Swoole\WebSocket\Server("0.0.0.0", 9514, SWOOLE_BASE);

$tcp = $server->listen("0.0.0.0", 9515, SWOOLE_SOCK_TCP);

$server->on("open", function ($serv, $req) {
    echo "new WebSocket Client, fd={$req->fd}\n";
});

$server->on("message", function ($serv, $frame) {
    echo "receive from {$frame->fd}:{$fr...

点击查看剩余70%

我知道答案,我要回答