public function parseRequestBody()

in common/protocol/fsof/DubboParser.php [257:307]


    public function parseRequestBody(DubboRequest &$request)
    {
        if ($request->getSerialization() != self::DUBBO_PROTOCOL_SERIALIZE_FAST_JSON) {
            $this->logger->error("unknown serialization type :" . $request->getSerialization());
            return false;
        }
        $cliData = substr($request->getFullData(), self::PACKAGE_HEDA_LEN);
        if ($cliData) {
            if ($request->isHeartbeatEvent()) {
                //心跳请求,不需要数据回送
            } else {
                $dataArr = explode(PHP_EOL, $cliData);
                $request->setDubboVersion(json_decode($dataArr[0], true));
                $request->setService(json_decode($dataArr[1], true));
                $request->setVersion(json_decode($dataArr[2], true));
                $methodName = json_decode($dataArr[3], true);
                if ($methodName == "\$invoke") {
                    //泛化调用
                    $request->setMethod(json_decode($dataArr[5], true));
                    $request->setParams(json_decode($dataArr[7], true));
                    $attach = json_decode($dataArr[8], true);
                } else {
                    //非泛化调用
                    $request->setMethod($methodName);
                    $paramTypes = json_decode($dataArr[4], true);
                    if ($paramTypes == "") {
                        //调用没有参数的方法
                        $request->setTypes(NULL);
                        $request->setParams(NULL);
                        $attach = json_decode($dataArr[5], true);
                    } else {
                        $typeArr = explode(";", $paramTypes);
                        $typeArrLen = count($typeArr);
                        $request->setParamNum($typeArrLen - 1);
                        $params = array();
                        for ($i = 0; $i < $typeArrLen - 1; $i++) {
                            $params[$i] = json_decode($dataArr[5 + $i], true);
                        }
                        $request->setParams($params);
                        $attach = json_decode($dataArr[5 + ($typeArrLen - 1)], true);
                    }
                }
                $request->setAttach($attach);
                if (array_key_exists('group', $attach)) {
                    $request->setGroup($attach['group']);
                }
                return $request;
            }
        }
        return false;
    }