<?php
use Workerman\Worker;
require_once './Workerman/Autoloader.php';
$ws_worker = new Worker("websocket://0.0.0.0:1100");
$ws_worker->count = 1;
// 当收到客户端发来的数据后返回$data给客户端
$ws_worker->onMessage = function($connection, $data) use ($ws_worker) {
foreach ($ws_worker->connections as $conn) {
$conn->send($data);
}
};
// 运行worker
Worker::runAll();
你的客户端发的