Create a Message with the given Type.

@param Message $msg

@return MessageInterface
@throws UnknownProtocolVersionException
437066
public static function createProtocolMessage(Message $msg)
    {
        $version = $msg->shift();
        if (!self::hasProtocolVersion(($version))) {
            throw new UnknownProtocolVersionException();
        }

        $type = $msg->shift();
        $class = self::getClassByType($type);

        return $class::fromMessage($msg);
    }
1159052
private function craft_new_msg($type, $jobId, $client, $data)
    {
        // Add client info to data
        $data->{'client'} = $client;
        // Build msg to send out
        $msg = array(
            'time'   => microtime(true),
            'type'   => $type,
            'jobId'  => $jobId,
            'data'   => $data
        );

        return $msg;
    }
188206
public function log($msg, $type = ShopgateLogger::LOGTYPE_ERROR)
    {
        return ShopgateLogger::getInstance()->log($msg, $type);
    }
780100
protected function createMessage(QueueSendMessageTransfer $messageTransfer)
    {
        $message = new AMQPMessage($messageTransfer->getBody(), $this->config->getMessageConfig());
        $headers = $messageTransfer->getHeaders();

        if ($headers !== null) {
            $headersTable = new AMQPTable($headers);
            $message->set('application_headers', $headersTable);
        }

        return $message;
    }
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;
    }
97037
public static function fromMessage(Message $msg)
    {
        $count = $msg->shift();

        if ($count != $msg->count()) {
            throw new InvalidArgumentException(
                'The action count is not the same as the actual number of actions.');
        }

        return new self($msg->toArray());
    }
323562
public function executeMsg(JobMessage $msg, ExecutionContext $execution = null)
    {
        if (null === $execution) {
            $execution = $this->createJobExecutionFromMessage($msg);
        }

        return $msg->execute($execution, $this->msgFactory);
    }
676245
public function create($msg)
    {
        // Verificar se mensagem pode ser traduzida pelo sistema da Lang do Laravel
        if (is_string($msg) && ($this->lang->has($msg)))
            $msg = $this->lang->get($msg);

        // Se msg for um objeto ou array deve fazer um print_r
        if (is_object($msg) || is_array($msg))
            $msg = print_r($msg, true);

        $args    = func_get_args();
        $args[0] = $msg;
        $msg     = trim(call_user_func_array('sprintf', $args));

        $code = $args[count($args) - 1];

        if (is_numeric($code))
            return new \Exception($msg, $code);
        else
            return new \Exception($msg);
    }
1213839
def create(message_type, priority=0):
    """"""
    message = protobuf.ProtocolMessage()
    message.type = message_type
    message.priority = priority
    return message
942908
public function getAuthenticateFromChallenge(ChallengeMessage $msg)
    {
        $token = [
            'id' => $this->authid,
            'exp' => time() + 60,
        ];
        $token = JWT::encode($token, Security::salt());
        return new AuthenticateMessage($token);
    }
520078
private function createMessageObject(string $type, string $message): Notification
    {
        $msg = new Notification();

        $msg->setType($type);
        $msg->setMessage($message);

        $this->handler->add($msg);

        return $msg;
    }
1182919
public static function make($type = self::TEXT)
    {
        if (!defined(__CLASS__.'::'.strtoupper($type))) {
            throw new InvalidArgumentException("Error Message Type '{$type}'");
        }

        $message = "Stoneworld\\Wechat\\Messages\\"
                    .str_replace(' ', '', ucwords(str_replace(array('-', '_'), ' ', $type)));

        return new $message();
    }
279246
public static function fromMessage(Message $msg)
    {
        $workerStatus = array();
        while ($msg->peek() !== null) {
            $id = $msg->shift();
            $actionCount = (int) $msg->shift();
            $actionList = array();
            for ($i = 0; $i < $actionCount; $i++) {
                $actionList[] = $msg->shift();
            }

            $workerStatus[$id] = array(
                'id'          => $id,
                'actionList'  => $actionList,
                'current'     => $msg->shift(),
                'ready'       => (bool) $msg->shift(),
                'valid'       => (bool) $msg->shift(),
            );
        }

        return new self($workerStatus);
    }
449774
public function createMessage(): Message
    {
        return (new Message($this))
            ->setChannel($this->options['channel'])
            ->setUsername($this->options['username'])
            ->setIcon($this->options['icon'])
            ->setAllowMarkdown($this->options['allow_markdown'])
            ->setMarkdownInAttachments($this->options['markdown_in_attachments'])
        ;
    }
1217971
public function processQueueItem(Message $msg)
    {
        $fID = (int) $msg->body;
        if ($fID > 0) {
            $file = $this->entityManager->find(File::class, $fID);
            if ($file !== null) {
                $fileVersion = $file->getApprovedVersion();
                if ($fileVersion !== null) {
                    if ($fileVersion->getTypeObject()->supportsThumbnails()) {
                        $imageWidth = (int) $fileVersion->getAttribute('width');
                        $imageHeight = (int) $fileVersion->getAttribute('height');
                        foreach ($this->getThumbnailTypeVersions() as $thumbnailTypeVersion) {
                            if ($thumbnailTypeVersion->shouldExistFor($imageWidth, $imageHeight, $file)) {
                                $this->thumbnailPathResolver->getPath($fileVersion, $thumbnailTypeVersion);
                            }
                        }
                    }
                }
            }
        }
    }
714713
public function createRequest(PushMessage $message) : RequestInterface
    {
        $host = $message->getPushSubscription()->getEndpoint()->getHost();
        $pushService = $this->pushServiceRegistry->getPushService($host);

        return $pushService->createRequest($message);
    }
1148456
public function sendMessage(Message $msg)
    {
        if (is_callable($this->sendMessageFunction)) {
            call_user_func_array($this->sendMessageFunction, [$msg]);
        }
    }