worker

说明:

  1. Worker Connection::$worker

此属性为只读属性,即当前connection对象所属的worker实例

范例

  1. use Workerman\Worker;
  2. require_once __DIR__ . '/Workerman/Autoloader.php';
  3. $worker = new Worker('websocket://0.0.0.0:8484');
  4. // 当一个客户端发来数据时,转发给当前进程所维护的其它所有客户端
  5. $worker->onMessage = function($connection, $data)
  6. {
  7. foreach($connection->worker->connections as $con)
  8. {
  9. $con->send($data);
  10. }
  11. };
  12. // 运行worker
  13. Worker::runAll();