DoraRPC\Server::onFinish PHP Method

onFinish() final public method

task process finished
final public onFinish ( $serv, $task_id, $data )
    public final function onFinish($serv, $task_id, $data)
    {
        /*
        //fixed the result more than 8k timeout bug
        if (strpos($data, '$$$$$$$$') === 0) {
            $tmp_path = substr($data, 8);
            $data = file_get_contents($tmp_path);
            unlink($tmp_path);
        }
        $data = unserialize($data);
        */
        $fd = $data["fd"];
        $guid = $data["guid"];
        //if the guid not exists .it's mean the api no need return result
        if (!isset($this->taskInfo[$fd][$guid])) {
            return true;
        }
        //get the api key
        $key = $this->taskInfo[$fd][$guid]["taskkey"][$task_id];
        //save the result
        $this->taskInfo[$fd][$guid]["result"][$key] = $data["result"];
        //remove the used taskid
        unset($this->taskInfo[$fd][$guid]["taskkey"][$task_id]);
        switch ($data["type"]) {
            case DoraConst::SW_MODE_WAITRESULT_SINGLE:
                $packet = Packet::packFormat("OK", 0, $data["result"]);
                $packet["guid"] = $guid;
                $packet = Packet::packEncode($packet, $data["protocol"]);
                $serv->send($fd, $packet);
                unset($this->taskInfo[$fd][$guid]);
                return true;
                break;
            case DoraConst::SW_MODE_WAITRESULT_MULTI:
                if (count($this->taskInfo[$fd][$guid]["taskkey"]) == 0) {
                    $packet = Packet::packFormat("OK", 0, $this->taskInfo[$fd][$guid]["result"]);
                    $packet["guid"] = $guid;
                    $packet = Packet::packEncode($packet, $data["protocol"]);
                    $serv->send($fd, $packet);
                    //$serv->close($fd);
                    unset($this->taskInfo[$fd][$guid]);
                    return true;
                } else {
                    //multi call task
                    //not finished
                    //waiting other result
                    return true;
                }
                break;
            case DoraConst::SW_MODE_ASYNCRESULT_SINGLE:
                $packet = Packet::packFormat("OK", 0, $data["result"]);
                $packet["guid"] = $guid;
                //flag this is result
                $packet["isresult"] = 1;
                $packet = Packet::packEncode($packet, $data["protocol"]);
                //sys_get_temp_dir
                $serv->send($fd, $packet);
                unset($this->taskInfo[$fd][$guid]);
                return true;
                break;
            case DoraConst::SW_MODE_ASYNCRESULT_MULTI:
                if (count($this->taskInfo[$fd][$guid]["taskkey"]) == 0) {
                    $packet = Packet::packFormat("OK", 0, $this->taskInfo[$fd][$guid]["result"]);
                    $packet["guid"] = $guid;
                    $packet["isresult"] = 1;
                    $packet = Packet::packEncode($packet, $data["protocol"]);
                    $serv->send($fd, $packet);
                    unset($this->taskInfo[$fd][$guid]);
                    return true;
                } else {
                    //multi call task
                    //not finished
                    //waiting other result
                    return true;
                }
                break;
            default:
                //
                return true;
                break;
        }
    }