/** * 接收数据 * @return bool | Swoole\Http\WebSocketFrame * @throws Swoole\Http\WebSocketException */ function recv() { if (!$this->handshake) { trigger_error("not complete handshake."); return false; } while (true) { $data = $this->socket->recv(); if (!$data) { return false; } $frame = $this->parser->pop($data); if ($frame) { return $frame; } } return false; }