Creates an instance of this class based on the Message.

@param Message $msg

@return ExecuteRequest
359013
public static function fromMessage(Message $msg)
    {
        return new self($msg->shift(), $msg->shift(), $msg->toArray());
    }
739150
public static function selector(
        $msg = '',
        $options = [],
        $default = null,
        $noValidMessage = null,
        $attemptTimes = 3,
        $failCloseMessage = false
    ) {
        $prompter = new SelectPrompter();

        $prompter->setOptions($options);

        static::prepareCallbackPrompter($prompter, $noValidMessage, $attemptTimes, $failCloseMessage);

        return $prompter->ask($msg, $default);
    }
516823
public static function parse(string $msg): Message
    {
        $obj = new self;
        $parts = explode("\r\n", $msg);
        $obj->body = MessageBody::parse(array_pop($parts));
        foreach ($parts as $line) {
            if ($line) {
                $pair = explode(': ', $line);
                $obj->headers[$pair[0]] = $pair[1];
            }
        }
        return $obj;
    }
1186228
public function enqueueMessage($msg, $type = 'message')
	{
		if ($this->messageStatus) {
			$event = new Event('onApplicationEnqueueMessage');
			$event->addArgument('message', $msg);
			$event->addArgument('type', $type);
			Factory::getDispatcher()->triggerEvent($event);
		}
	}
982385
public static function decode($msg)
    {
        try {
            $data = json_decode($msg, true);

            return $data;
        } catch (\Exception $e) {
            throw new \InvalidArgumentException('Invalid json format');
        }
    }
1149272
public function handle($msg)
    {
        if (!$msg instanceof JobMessage) {
            if ($this->logger) {
                $this->logger->info('No more message');
            }

            return false;
        }

        return $this->handleMsg($msg);
    }
572280
public static function clearMsg($msg)
    {
        $nmsg = str_replace([' standalone="no"', 'default:', ':default', "\n", "\r", "\t"], '', $msg);
        $nnmsg = str_replace('> ', '>', $nmsg);
        if (strpos($nnmsg, '> ')) {
            $nnmsg = self::clearMsg((string) $nnmsg);
        }

        return $nnmsg;
    }
736632
public function debug($msg = true)
    {
        if (is_bool($msg)) {
            $this->debug = $msg;

            return $this;
        }

        if (is_object($msg)) {
            throw $this->exception('Do not debug objects');
        }

        // The rest of this method is obsolete
        if ((isset($this->debug) && $this->debug)
            || (isset($this->app->debug) && $this->app->debug)
        ) {
            $this->app->outputDebug($this->owner, $msg);
        }
    }
193778
private function messageToResponse($msg)
    {
        $response = new ResponseMessage($msg);
        $actionId = $response->getActionId();
        if (is_null($actionId)) {
            $actionId = $this->lastActionId;
            $response->setActionId($this->lastActionId);
        }
        return $response;
    }
154556
protected function logInfo(string $msg)
    {
        $this->logger->info('CMD: ' . $msg);
        $this->out->writeln("<info>$msg<info>");
    }
1003307
public function info($msg)
    {
        if ($this->iniGetBool('display_errors') === true) {
            $this->write((string)$msg, 'INFO');
        }

        return $this;
    }
590826
public function Message($msg = '', $append = false)
    {
        if (is_null($msg)) {
            $this->_msg = array();
        } elseif (is_array($msg)) {
            if ($append) {
                $this->_msg = array_merge($this->_msg, $msg);
            } else {
                $this->_msg = $msg;
            }
            return $this->_msg;
        }
        return $this->_msg;
    }
1201782
public function execute(AMQPMessage $msg)
    {

        $logger = $this->container->get("logger");

        $jsonBody = json_decode($msg->body);
        if ($jsonBody == null){
            $logger->error("JSON NULL");
            return false;
        }
        $messagePackageId = json_decode($msg->body)->messagePackageId;

        $logger->error('tGuardado correctamente 1: ' . $messagePackageId);

        /** @var EntityManager $em */
        $em = $this->container->get('doctrine.orm.default_entity_manager');
        /** @var MessageHelper $messageHelper */
        $messageHelper = $this->container->get('sopinet_chatbundle_messagehelper');
        $reMessagePackage = $em->getRepository('SopinetChatBundle:MessagePackage');
        /** @var MessagePackage $messagePackage */
        $messagePackage = $reMessagePackage->findOneById($messagePackageId);
        if ($messagePackage == null) return false;
        if ($messagePackage->getMessage() == null) return false;;

        $logger->error('Guardado correctamente 2: ' . $messagePackageId);

        // TODO: This part should be same that <SEARCH_DUPLICATE>
        if ($messagePackage->getToDevice()->getDeviceType() == Device::TYPE_ANDROID) {
            $messagePackage->setProcessed(true); // Yes, processed
        } elseif (
            $messagePackage->getToDevice()->getDeviceType() == Device::TYPE_IOS ||
            $messagePackage->getToDevice()->getDeviceType() == Device::TYPE_VIRTUALNONE
        ) {
            $messagePackage->setProcessed(false); // Not processed
        }
        $em->persist($messagePackage);
        $em->flush();
        
        $response = $messageHelper->sendRealMessageToDevice($messagePackage->getMessage(), $messagePackage->getToDevice(), $messagePackage->getToUser(), $this->request, true);
        if ($response) {
            $messagePackage->setStatus(MessagePackage::STATUS_OK);
            if ($messagePackage->getMessage()->getMySenderEmailHas($this->container)) {
                $messageHelper->sendMessageToEmail($messagePackage->getMessage(), $messagePackage->getToUser());
            }
        } else {
            $messagePackage->setStatus(MessagePackage::STATUS_KO);
        }

        $em->persist($messagePackage);
        $em->flush();

        // TODO: End <SEARCH_DUPLICATE>

        return true;
    }
1311211
public function createRequest(PushMessage $message) : RequestInterface
    {
        $request = new Request(
            'POST',
            $this->getUrl($message),
            $this->getHeaders($message),
            $this->getBody($message)
        );

        return $request;
    }
75652
public function create($sessionId, $message, $contexts = [])
    {
        try {
            $step = $this->getStep($sessionId, $message, $contexts);
        } catch (\Exception $error) {
            return $this->actionMapping->error($sessionId, $error);
        }

        return $this->performStep($sessionId, $step);
    }
1298526
public function handlesMessage(Message $msg)
    {
        $handledMsgCodes = [
            Message::MSG_CALL,
            Message::MSG_CANCEL,
            Message::MSG_REGISTER,
            Message::MSG_UNREGISTER,
            Message::MSG_YIELD,
            Message::MSG_INTERRUPT
        ];

        if (in_array($msg->getMsgCode(), $handledMsgCodes)) {
            return true;
        } elseif ($msg instanceof ErrorMessage && $msg->getErrorMsgCode() === Message::MSG_INVOCATION) {
            return true;
        } elseif ($msg instanceof ErrorMessage && $msg->getErrorMsgCode() === Message::MSG_INTERRUPT) {
            return true;
        } else {
            return false;
        }
    }
1198616
public function onClientHandlerMessage(ClientHandlerJobRequest $msg)
    {
        $request = new Request($msg->getRequestId(), $msg->getActionName(), $msg->getParameters());
        $this->addRequest($request);

        $this->getStream('clientHandler')->send(
            new ClientHandlerJobResponse(
                $msg->getRequestId(),
                $this->getId()
            )
        );
    }