Send a message to notify the client handlers that the workerhandler is
still alive.

@param string|null $requestId

@return void
346572
public function notify($requestId = null)
    {
        $this->getStream('status')->send(
            new WorkerHandlerStatus($this->getId(), $requestId)
        );
    }
44641
public function sendToWorkerHandler(MessageInterface $msg)
    {
        if (!$this->isWorkerHandlerReady()) {
            $this->getLogger()->debug('WorkerHandler socket not ready to send.');

            return;
        }

        $this->workerHandlerReady = false;
        $this->workerHandlerStream->send($msg);
    }
287992
public function onWorkerStop(SwServer $server, int $workerId)
    {
        $workerType = $server->taskworker ? 'task' : 'worker';

        // {{ log
        $this->get('logger')->info('结束 Worker 进程', [
            'id' => $workerId,
            'type' => ucfirst($workerType)
        ]);
        // }}

        if ($workerType === 'worker') {
            $this->shutdownWorkerStartItems();
            $this->callProtocolMethod('onStop', $server, $workerId);
        }

        unset($workerType);
    }
1152873
public function stopWorker(int $workerId = null): bool
    {
        if ($this->server) {
            return $this->server->stop($workerId);
        }

        return false;
    }
579682
public void fail(String requestId) throws TException
    {
        int index = this.requestedMap.remove(requestId);
        DRPCInvocationsClient client = this.clients.get(index);
        client.failRequest(requestId);
    }
356030
public function addRequest($messageBody, $server, $requestId, $routingKey = '')
    {
        if (empty($requestId)) {
            throw new \InvalidArgumentException("You must provide a request ID");
        }
        $this->setParameter('correlation_id', $requestId);
        $this->setParameter('reply_to', $this->queueName);

        $message = new AMQPMessage(
            $messageBody,
            $this->getParameters()
        );

        $this->channel
            ->basic_publish($message, $server . '-exchange', $routingKey);

        $this->requests++;
    }
1343484
private function writeResponse(int $requestId, string $headerData, $stream): void
    {
        $data = $headerData;
        $eof  = false;
        $maxSize = 65535;
        fseek($stream, 0, SEEK_SET);

        do {
            $dataLength = strlen($data);

            if ($dataLength < $maxSize && !$eof && !($eof = feof($stream))) {
                $readLength  = $maxSize - $dataLength;
                $data       .= fread($stream, $readLength);
                $dataLength  = strlen($data);
            }

            $writeSize = min($dataLength, $maxSize);
            $writeData = substr($data, 0, $writeSize);
            $data      = substr($data, $writeSize);

            $this->writeRecord($requestId, DaemonInterface::FCGI_STDOUT, $writeData);
        } while ($writeSize === $maxSize);

        $this->writeRecord($requestId, DaemonInterface::FCGI_STDOUT);
    }
150759
private function readNameValuePair(int $requestId, ?string &$buffer): void
    {
        $nameLength  = $this->readFieldLength($buffer);
        $valueLength = $this->readFieldLength($buffer);

        $contentFormat = (
            'a'.$nameLength.'name/'.
            'a'.$valueLength.'value/'
        );

        $content = unpack($contentFormat, $buffer);
        $this->requests[$requestId]['params'][$content['name']] = $content['value'];

        $buffer = substr($buffer, $nameLength + $valueLength);
    }
1195138
public function sendEvent($id, $data, $eventName)
    {
        $this->sendBlock($id, $data, $eventName);
        $this->flush();
    }
88743
private void notifyHandlers(ApiUser apiUser) {
        for(ServerUserHandlerClass handler : serverUserEventHandler) {
            Object userAgent = checkUserAgent(handler, apiUser);
            ReflectMethodUtil.invokeHandleMethod(
                    handler.getHandleMethod(), 
                    handler.newInstance(), 
                    context, 
                    userAgent);
        }
    }
887160
public function sendAsync(RequestInterface $request, callable $success = null, callable $error = null)
    {
        $this->emit('beforeRequest', [$request]);
        $this->sendAsyncInternal($request, $success, $error);
        $this->poll();
    }
592824
private function sendHttpFoundationResponse(int $requestId, HttpFoundationResponse $response): void
    {
        $statusCode = $response->getStatusCode();

        $headerData  = "Status: {$statusCode}\r\n";
        $headerData .= $response->headers."\r\n";

        $stream = fopen('php://memory', 'r+');
        fwrite($stream, $response->getContent());

        $this->writeResponse($requestId, $headerData, $stream);
    }
621433
public function listen($errorHandler = null)
    {
        $response = $this->execute($errorHandler);

        $this->output->respond($response);
    }
342473
public function processResponse($requestId = null)
    {
        $this->_errors = array();
        $this->_errorReason = null;
        if (isset($_POST) && isset($_POST['SAMLResponse'])) {
            // AuthnResponse -- HTTP_POST Binding
            $response = new OneLogin_Saml2_Response($this->_settings, $_POST['SAMLResponse']);
            $this->_lastResponse = $response->getXMLDocument();

            if ($response->isValid($requestId)) {
                $this->_attributes = $response->getAttributes();
                $this->_attributesWithFriendlyName = $response->getAttributesWithFriendlyName();
                $this->_nameid = $response->getNameId();
                $this->_nameidFormat = $response->getNameIdFormat();
                $this->_nameidNameQualifier = $response->getNameIdNameQualifier();
                $this->_authenticated = true;
                $this->_sessionIndex = $response->getSessionIndex();
                $this->_sessionExpiration = $response->getSessionNotOnOrAfter();
                $this->_lastMessageId = $response->getId();
                $this->_lastAssertionId = $response->getAssertionId();
                $this->_lastAssertionNotOnOrAfter = $response->getAssertionNotOnOrAfter();
            } else {
                $this->_errors[] = 'invalid_response';
                $this->_errorReason = $response->getError();
            }
        } else {
            $this->_errors[] = 'invalid_binding';
            throw new OneLogin_Saml2_Error(
                'SAML Response not found, Only supported HTTP_POST Binding',
                OneLogin_Saml2_Error::SAML_RESPONSE_NOT_FOUND
            );
        }
    }
128866
private function handleRequest(RequestInterface $request, ResponseInterface $response): void
    {
        foreach ($this->routes as $route) {
            $routeMatch = $route->matches($request);

            if ($routeMatch === null) {
                continue;
            }

            $controllerClass = $routeMatch->getControllerClassName();
            $controller = new $controllerClass();

            /** @var ControllerInterface $controller */
            $controller->processRequest($this, $request, $response, $routeMatch->getAction(), $routeMatch->getParameters());

            return;
        }

        $response->setStatusCode(new StatusCode(StatusCode::NOT_FOUND));
    }
899401
public function getCallByRequestId($requestId)
    {
        /** @var Call $call */
        foreach ($this->calls as $call) {
            if ($call->getInvocationMessage()->getRequestId() === $requestId) {
                return $call;
            }
        }

        return false;
    }
909348
def restore_event(self, requestId):
        
        with self.__requests:
            if requestId not in self.__requests:
                self.__requests[requestId] = RequestEvent(requestId)
                return True
        return False