DoraRPC\Client::getAsyncData PHP Метод

getAsyncData() публичный Метод

public getAsyncData ( )
    public function getAsyncData()
    {
        //wait all the async result
        //when  timeout all the error will return
        //这里有个坑,我不知道具体哪个client需要recive
        while (1) {
            if (count(self::$asynclist) > 0) {
                foreach (self::$asynclist as $k => $client) {
                    if ($client->isConnected()) {
                        $data = $client->recv();
                        if ($data !== false && $data != "") {
                            $data = Packet::packDecode($data);
                            if (isset(self::$asynclist[$data["data"]["guid"]]) && isset($data["data"]["isresult"]) && $data["data"]["isresult"] == 1) {
                                //ok recive an async result
                                //remove the guid on the asynclist
                                unset(self::$asynclist[$data["data"]["guid"]]);
                                //add result to async result
                                self::$asynresult[$data["data"]["guid"]] = $data["data"];
                                self::$asynresult[$data["data"]["guid"]]["fromwait"] = 0;
                                continue;
                            } else {
                                //not in the asynclist drop this packet
                                continue;
                            }
                        } else {
                            //remove the result
                            unset(self::$asynclist[$k]);
                            self::$asynresult[$k] = Packet::packFormat("the recive wrong or timeout", 100009);
                            continue;
                        }
                    } else {
                        //remove the result
                        unset(self::$asynclist[$k]);
                        self::$asynresult[$k] = Packet::packFormat("Get Async Result Fail: Client Closed.", 100012);
                        continue;
                    }
                }
                // foreach the list
            } else {
                break;
            }
        }
        //while
        $result = self::$asynresult;
        self::$asynresult = array();
        return Packet::packFormat("OK", 0, $result);
    }