process YieldMessage

@param \Thruway\Session $session
@param \Thruway\Message\YieldMessage $msg
978254
private function processYield(Session $session, YieldMessage $msg)
    {

        /* @var $call Call */
        $call = isset($this->callInvocationIndex[$msg->getRequestId()]) ? $this->callInvocationIndex[$msg->getRequestId()] : null;

        if (!$call) {
            $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg));
            Logger::error($this, "Was expecting a call");

            return;
        }

        $keepIndex = $call->processYield($session, $msg);

        if (!$keepIndex) {
            $this->removeCall($call);
        }

        /* @var $procedure \Thruway\Procedure */
        $procedure = isset($this->procedures[$call->getCallMessage()->getUri()]) ? $this->procedures[$call->getCallMessage()->getUri()] : null;
        if ($procedure && $procedure->getAllowMultipleRegistrations()) {
            $procedure->processQueue();
        }

        //Process queues on other registrations if we can take more requests
        if ($session->getPendingCallCount() == 0 && $this->registrationsBySession->contains($session)) {
            $this->processQueue($session);
        }

    }
228711
public function tick( $msg, $emit = true ) : \Generator {
		$percentage = $this->j;
		if ( $percentage < $this->start ) {
			$percentage = $this->start;
		} elseif ( $percentage > $this->end ) {
			$percentage = $this->end;
		}
		$msg = trim( $msg ) . sprintf( __( ' (%1$d of %2$d)', 'pressbooks' ), $this->i, $this->total );
		if ( $emit ) {
			yield $percentage => $msg;
		}
		++$this->i;
		if ( $this->i % $this->chunks === 0 ) {
			++$this->j;
		}
	}
619654
public static function spinner(string $msg = '', $ended = false): void
    {
        static $chars = '-\|/';
        static $counter = 0;
        static $lastTime = null;

        $tpl = (Cli::isSupportColor() ? "\x0D\x1B[2K" : "\x0D\r") . '%s';

        if ($ended) {
            printf($tpl, $msg);
            return;
        }

        $now = \microtime(true);

        if (null === $lastTime || ($lastTime < $now - 0.1)) {
            $lastTime = $now;
            // echo $chars[$counter];
            printf($tpl, $chars[$counter] . $msg);
            $counter++;

            if ($counter > \strlen($chars) - 1) {
                $counter = 0;
            }
        }
    }
1336292
public function converse($sessionId, $message = null, Context $context = null, $stepIteration = self::MAX_STEPS_ITERATION)
    {
        return $this->conversation->converse($sessionId, $message, $context, $stepIteration);
    }
595145
private function _log($resources, $msg = 'Disabled following resources:')
    {
        if ($this->enableLog) {
            $this->writeLog($msg . "\n" . var_export($resources, true));
        }
    }
1085826
public function throwError($msg)
    {
        if ($this->ignoreErrors) {
            return;
        }

        if (func_num_args() > 1) {
            $msg = call_user_func_array('sprintf', func_get_args());
        }

        $line = $this->sourceLine;
        $msg = "$msg: line: $line";

        throw new CompilerException($msg);
    }
743740
public static void processMessageToMatchSession(HttpMessage message, HttpSession session) {
		processMessageToMatchSession(message, message.getRequestHeader().getHttpCookies(), session);
	}
625546
protected function onMasterMessage(string $message): Generator
    {
        yield Dispatcher::async($this->broadcast(Frame::encode($message), false));
    }
587508
private function audit($msg)
    {
        // Log the message if enabled
        if ($this->app['config']->get('general/debug_permission_audit_mode', false)) {
            $this->app['logger.system']->info($msg, ['event' => 'authentication']);
        }
    }
263225
public function onClientMessage(MessageInterface $msg, $routing)
    {
        $client = $this->client(array_shift($routing));

        if ($msg instanceof ExecuteRequest) {
            $this->clientRequest($client, $msg);

            return;
        }

        if ($msg instanceof FetchRequest) {
            $this->clientFetch($client, $msg);

            return;
        }

        $this->getLogger()->info('Invalid message type: '.get_class($msg).'.');
    }
1282478
public function debug(string $msg) {
		if ($this->level > self::DEBUG)
			return;
		$this->write('DEB', $msg);
	}
1093626
public function processUnregister(Session $session, UnregisterMessage $msg)
    {
        for ($i = 0; $i < count($this->registrations); $i++) {
            /** @var Registration $registration */
            $registration = $this->registrations[$i];
            if ($registration->getId() == $msg->getRegistrationId()) {

                // make sure the session is the correct session
                if ($registration->getSession() !== $session) {
                    $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.no_such_registration'));
                    //$this->manager->warning('Tried to unregister a procedure that belongs to a different session.');
                    return false;
                }

                array_splice($this->registrations, $i, 1);

                // TODO: need to handle any calls that are hanging around

                $session->sendMessage(UnregisteredMessage::createFromUnregisterMessage($msg));
                return true;
            }
        }

        $session->sendMessage(ErrorMessage::createErrorMessageFromMessage($msg, 'wamp.error.no_such_registration'));

        return false;
    }
356414
public static function createRegistrationFromRegisterMessage(Session $session, RegisterMessage $msg)
    {
        $registration = new self($session, $msg->getProcedureName());
        $options      = $msg->getOptions();

        if (isset($options->disclose_caller) && $options->disclose_caller === true) {
            $registration->setDiscloseCaller(true);
        }

        if (isset($options->invoke)) {
            $registration->setInvokeType($options->invoke);
        } else {
            if (isset($options->thruway_multiregister) && $options->thruway_multiregister === true) {
                $registration->setInvokeType(self::THRUWAY_REGISTRATION);
            } else {
                $registration->setInvokeType(self::SINGLE_REGISTRATION);
            }
        }

        return $registration;
    }
335981
private function onMessage($msg, $socket) {
        try {
            $payload = @json_decode($msg, true);
            if (!$payload) {
                $this->response($socket, ['error' => 403, 'message' => 'error request']);

                return;
            }
            $command = isset($payload['command']) ? $payload['command'] : 'status';
            $service = isset($payload['args']['service']) ? $payload['args']['service'] : '';
            switch ($command) {
                case 'stop':
                    if ($service) {
                        $rst = $this->stopService($service);
                        $this->response($socket, ['status' => $rst ? 'done' : 'fail']);
                    } else {
                        $this->response($socket, ['status' => 'done']);
                        $this->shutdown = true;
                        $this->rSignal  = SIGTERM;
                    }
                    break;
                case 'start':
                    if ($service) {
                        $rst = $this->startService($service);
                        $this->response($socket, ['status' => $rst ? 'done' : 'fail']);
                    } else {
                        $this->response($socket, ['status' => 'fail']);
                    }
                    break;
                case 'reload':
                    $rst = $this->reloadConfig(null, $service);
                    $this->response($socket, ['status' => $rst ? 'done' : 'fail']);
                    break;
                case 'ps':
                    if ($service) {
                        if (isset($this->services[ $service ])) {
                            $pids = isset($this->services[ $service ]['pids']) ? $this->services[ $service ]['pids'] : [];
                            $this->response($socket, [
                                'ps'   => [$service => $pids],
                                'ssid' => posix_getpid()
                            ]);
                        } else {
                            $this->response($socket, ['ps' => [], 'ssid' => posix_getpid()]);
                        }
                    } else {
                        $ps = [];
                        foreach ($this->services as $s => $ser) {
                            $ps[ $s ] = isset($ser['pids']) ? $ser['pids'] : [];
                        }
                        $this->response($socket, ['ps' => $ps, 'ssid' => posix_getpid()]);
                    }
                    break;
                case 'status':
                default:
                    if ($service) {
                        if (isset($this->services[ $service ])) {
                            $this->response($socket, [
                                'status' => $this->services[ $service ]['status'],
                                'detail' => $this->services[ $service ]
                            ]);
                        } else {
                            $this->response($socket, ['status' => 'unknown', 'detail' => []]);
                        }
                    } else {
                        $this->response($socket, ['status' => 'running', 'services' => $this->services]);
                    }
            }
        } catch (\Exception $e) {
            $this->response($socket, ['error' => 500, 'msg' => $e->getMessage()]);
        }
    }
141384
public function onWorkerMessage(MessageInterface $msg)
    {
        if ($msg instanceof Protocol\ActionListRequest) {
            $this->getLogger()->debug('[SERVICE] Returning list of actions.');
            $this->stream->send(new Protocol\ActionListResponse($this->getActionList()));

            return;
        }

        if ($msg instanceof Protocol\ExecuteJobRequest) {
            $requestId = $msg->getRequestId();
            $action = $msg->getAction();

            $this->getLogger()->debug('[SERVICE] Job for action: '.$action.' with id: '.$requestId);

            $params = array();
            $serialized = $msg->getParams();
            foreach ($serialized as $param) {
                $params[] = $this->getSerializer()->unserialize($param);
            }

            if (!isset($this->actions[$action])) {
                $this->getLogger()->notice('[SERVICE] Action '.$action.' not found.');
                $this->stream->send(new Protocol\ActionNotFound($requestId, $action));

                return;
            }

            $return = $this->execute($action, $params);
            $sendReturn = $this->getSerializer()->serialize($return);

            $this->stream->send(new Protocol\ExecuteJobResponse($requestId, $sendReturn));

            return;
        }

        throw new RuntimeException('Invalid request.');
    }
1065821
private QYBaseRespMsg processMessageHandle(QYBaseReqMsg msg){
        if(CollectionUtil.isEmpty(messageHandles)){
            synchronized (LOCK){
                messageHandles = this.initMessageHandles();
            }
        }
        if(CollectionUtil.isNotEmpty(messageHandles)){
            for(QYMessageHandle messageHandle : messageHandles){
                QYBaseRespMsg resultMsg = null;
                boolean result;
                try{
                    result = messageHandle.beforeHandle(msg);
                }catch (Exception e){
                    result = false;
                }
                if(result){
                    resultMsg = messageHandle.handle(msg);
                }
                if(BeanUtil.nonNull(resultMsg)){
                    return resultMsg;
                }
            }
        }
        return null;
    }
678811
protected function processPublish(Session $session, PublishMessage $msg)
    {
        if ($msg->getPublicationId() === null) {
            $msg->setPublicationId(Utils::getUniqueId());
        }

        /** @var SubscriptionGroup $subscriptionGroup */
        foreach ($this->subscriptionGroups as $subscriptionGroup) {
            $subscriptionGroup->processPublish($session, $msg);
        }

        if ($msg->acknowledge()) {
            $session->sendMessage(new PublishedMessage($msg->getRequestId(), $msg->getPublicationId()));
        }
    }