处理消息

@param Bag $message

@return mixed
433381
protected function handleMessage($message)
    {
        if (!is_null($response = $this->call('message.*', array($message)))) {
            return $response;
        }

        return $this->call("message.{$message['MsgType']}", array($message));
    }
516523
public function send(Message $message)
    {
        $rawMessage = $this->getMessageEncoder()->encode($message);

        // test if we need to split the message to multiple chunks
        // chunkSize == 0 allows for an unlimited packet-size, and therefore
        // disables chunking
        if ($this->chunkSize && strlen($rawMessage) > $this->chunkSize) {
            return $this->sendMessageInChunks($rawMessage);
        }

        // send message in one packet
        $this->write($rawMessage);

        return 1;
    }
1359012
public function resolveCustomMessage($message)
    {
        preg_match_all('/\{[\w.| ]+\}/', $message, $segments);
        foreach (current($segments) as $segment) {
            $s    = str_replace(['{', '}'], '', $segment);
            $keys = explode('|', $s);

            if (empty($keys[1]) && isset($keys[2])) {
                $keys[1] = $this->callback($keys[2]);
            }

            $valueSegmented = $this->getValueSegmented($this, $keys[0], isset($keys[1]) ? $keys[1] : false);
            if (!$valueSegmented) {
                return false;
            }
            $message = str_replace($segment, $valueSegmented, $message);
        }

        return $message;
    }
754191
public function logInfo($message)
    {
        if (func_num_args() > 1) {
            $message = $this->_prepareLogMessage(func_get_args());
        }

        return $this->_log(Zend_Log::INFO, $message);
    }
144399
protected function parseMessage($message)
    {
        $headerAndBody = explode("\r\n\r\n", $message, 2);
        $headers = explode("\r\n", $headerAndBody[0]);

        return [$this->parseHeader($headers), $headerAndBody[1]];

    }
465278
private function msg($msg): string
    {
        // 将数组转为字符串
        if (is_array($msg) or is_object($msg) or is_bool($msg)) {
            return json($msg);
        }

        // 返回可显示的字符串
        return (string)$msg;
    }
350061
protected function checkout(MessageBag $messages)
    {
        $html       = '';
        $hasError   = false;
        $hasSuccess = false;

        foreach (['error', 'info', 'success', 'warning'] as $key) {
            if ($messages->has($key)) {
                $hasError   = (!$hasError && $key == 'error');
                $hasSuccess = (!$hasSuccess && $key == 'success');

                $flashMessages = $messages->setFormat('<div class="activity-item"> <i class="fa ' . $this->mapping[$key] . '"></i> <div class="activity">:message</div>')->get($key);


                array_walk($flashMessages, function($current) use ($key, &$html) {
                    $html .= "generate('{$key}', '{$current}');\n";
                });
            }
        }
        return $html;
    }
181481
public function translate($message)
    {
        // message must be an array
        if (!is_array($message)) {
            return null;
        }

        // the following keys are required to construct a topic event object
        $keys = ['topic', 'event', 'version'];
        foreach ($keys as $k) {
            if (!isset($message[$k])) {
                return null;
            }
        }

        // don't include the topic, event and version as attributes
        $attributes = $message;
        unset($attributes['topic'], $attributes['event'], $attributes['version']);

        return new TopicEvent($message['topic'], $message['event'], $message['version'], $attributes);
    }
793363
public function translateContext($context, $message)
    {
        $key = $context . chr(4) . $message;
        if (isset($this->translations[$key])) {
            return $this->translations[$key];
        } else {
            return $message;
        }
    }
855682
public function translate($message)
    {
        $locale = $this->configuration
            ->get('i18n.locale', $this->fallbackLocale);

        return $this->getTranslatorService()
            ->translate($message, $this->domain, $locale);
    }
1031998
protected function getJsonPayload($message)
    {
        if (is_array($message) || $message instanceof JsonSerializable) {
            return json_encode($message);
        } elseif (method_exists($message, 'toJson')) {
            return $message->toJson();
        } elseif (method_exists($message, 'toArray')) {
            return json_encode($message->toArray());
        } elseif (is_string($message) && is_array(json_decode($message, true))) {
            return $message;
        }
    }
692506
protected function normalizeBag($bag) : Collection
	{
		return Collection::make($bag)->filter(function ($item) {
			return is_string($item) ? trim($item) !== '' : $item;
		});
	}
773717
protected function stringifyMessage($message)
    {
        if (is_array($message) || is_object($message) || is_bool($message)) {
            return (string)var_export($message, true);
        }
        return (string)$message;
    }
1032648
public function error($message)
    {
        $args = func_get_args();
        array_shift($args);
        return $this->log(Log::Error, $message, $args);
    }
1143415
public function messages(): MessageBagContract
    {
        if ($this->validator === null) {
            $this->validate();
        }

        if ( ! $this->validator->fails()) {

            return new MessageBag;
        }

        return $this->validator->messages();
    }
55293
public function prefixWithTimestamp($message)
    {
        if (!(
            $this->prefix & ConsoleOutput::PREFIX_TIMESTAMP ||
            $this->prefix & ConsoleOutput::PREFIX_DURATION ||
            $this->prefix & ConsoleOutput::PREFIX_CLASSNAME
        )) {
            return $message;
        }

        $diff = $this->previous ? round((microtime(true) - $this->previous), 3) : 0;
        $this->previous = microtime(true);

        $microtime = explode(' ', (string) microtime())[0];
        $microtime = substr((string) round($microtime, 3), 2, 3);
        $microtime = str_pad(is_bool($microtime) ? '0' : $microtime, 3, '0');

        $prefixs = [];

        if ($this->prefix & ConsoleOutput::PREFIX_TIMESTAMP) {
            $prefixs[] = sprintf(
                '<fg=yellow>[%s.%s]</>',
                date('Y-m-d H:i:s'),
                $microtime
            );
        }

        if ($this->prefix & ConsoleOutput::PREFIX_DURATION) {
            $prefixs[] = sprintf(
                '<fg=cyan>[+%s s]</>',
                str_pad((string) $diff, 9, ' ', STR_PAD_LEFT)
            );
        }

        if ($this->prefix & ConsoleOutput::PREFIX_CLASSNAME && isset($this->command)) {
            $prefixs[] = sprintf(
                '<fg=magenta>[%s]</>',
                get_class($this->command)
            );
        }

        $prefix = implode(' ', $prefixs);

        $prefix = $this->getFormatter()->format($prefix);
        $message = str_pad($prefix, strlen($prefix) + 1) . $message;

        return $message;
    }
129262
public function getChannel($message)
    {
        if (is_int($message)) {
            return $this->channels[$message];
        }
        return $this->channels[$message->getChannel()];
    }