Returns a ResponseMessage from a raw string that came from asterisk.

@param string $msg Raw string.

@return \PAMI\Message\Response\ResponseMessage
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;
    }
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()
            )
        );
    }
20850
public function toJsonString(WxSendMsg $msg)
    {
        if ($msg instanceof WxSendTextMsg) {
            return $this->sendTextMsgToJsonString($msg);
        } elseif ($msg instanceof WxSendImageMsg) {
            return $this->sendImageMsgToJsonString($msg);
        } elseif ($msg instanceof WxSendVoiceMsg) {
            return $this->sendVoiceMsgToJsonString($msg);
        } elseif ($msg instanceof WxSendVideoMsg) {
            return $this->sendVideoMsgToJsonString($msg);
        } elseif ($msg instanceof WxSendMusicMsg) {
            return $this->sendMusicMsgToJsonString($msg);
        } elseif ($msg instanceof WxSendNewsMsg) {
            return $this->sendNewsMsgToJsonString($msg);
        }

        throw new \InvalidArgumentException("unknown wx send msg");
    }
1125412
protected function getLocaleContext( array $msg )
	{
		$lcontext = clone $this->getContext();
		$manager = \Aimeos\MShop::create( $lcontext, 'locale' );

		$sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' );
		$localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE );

		return $lcontext->setLocale( $localeItem );
	}
294926
public static function processMessage ($msg)
  {
    $msg = preg_replace_callback ('#<path>([^<]*)</path>#', function ($m) {
      return ErrorConsole::errorLink ($m[1], 1, 1, self::shortFileName ($m[1]));
    }, $msg);
    return $msg;
  }
1371539
public function url($msg)
    {
        if(strlen(trim($this->_value)) > 0 && filter_var($this->_value, FILTER_VALIDATE_URL) === FALSE) {
            $this->_errors[] = $msg;
        }
        return $this;
    }
830026
public function receive($raw)
    {
        if ($this->verify) {
            $this->validateRequest();
        }

        $incomingMessage = $this->createIncomingMessage();
        $incomingMessage->setRaw($raw->get());
        $incomingMessage->setMessage($raw->get('resource_uri'));
        $incomingMessage->setFrom($raw->get('from_number'));
        $incomingMessage->setId($raw->get('message_uuid'));
        $incomingMessage->setTo($raw->get('to_number'));

        return $incomingMessage;
    }
371199
public static function fromMessage(Message $msg)
    {
        $requestId = $msg->shift();
        $actionName = $msg->shift();
        $parameters = $msg->toArray();

        return new self($requestId, $actionName, $parameters);
    }
1343225
public function parseServerFirstMessage($msg)
    {
        $i = $r = $s = false;

        foreach (explode(',', $msg) as $val) {
            list($attr, $aval) = array_map('trim', explode('=', $val, 2));

            switch ($attr) {
            case 'i':
                $this->_iterations = intval($aval);
                $i = true;
                break;

            case 'r':
                /* Beginning of server-provided nonce MUST be the same as the
                 * nonce we provided. */
                if (strpos($aval, $this->_nonce) !== 0) {
                    return false;
                }
                $this->_nonce = $aval;
                $r = true;
                break;

            case 's':
                $this->_salt = base64_decode($aval);
                $s = true;
                break;
            }
        }

        if ($i && $r && $s) {
            $this->_authmsg .= ',' . $msg;
            return true;
        }

        return false;
    }
1049524
public static function confirm($msg) {
        print $msg . ' > ';
        system('stty -icanon');
        $handle = fopen('php://stdin', 'r');
        $char = fgetc($handle);
        system('stty icanon');
        print "\n";

        $allowedResponses = array('y', 'Y', 'n', 'N');
        if (!in_array($char, $allowedResponses)) {
            // nag 'em some more
            Garp_Cli::errorOut('Please respond with a clear y or n');
            return static::confirm($msg);
        }
        return $char === 'y' || $char === 'Y';
    }
59993
protected function getResponseMessage()
    {

        // read the first 4 bytes which include the length of the response
        $lengthEncoded = $this->client->read(4);

        if (strlen($lengthEncoded) < 4) {
            return new Message('', Message::TYPE_RESPONSE_VALUE);
        }

        $lengthInBytes = unpack('V1size', $lengthEncoded)['size'];

        if ($lengthInBytes <= 0) {
            return new Message('', Message::TYPE_RESPONSE_VALUE);
        }

        $responseData = $this->client->read($lengthInBytes);

        // return an empty message if the server did not send any response
        if (null === $responseData) {
            return new Message('', Message::TYPE_RESPONSE_VALUE);
        }

        $responseMessage = new Message();
        $responseMessage->initializeFromRconData($responseData);

        if ($lengthInBytes >= 4000) {
            $this->handleFragmentedResponse($responseMessage);
        }

        return $responseMessage;
    }
28108
public static function fromMessage(Message $msg)
    {
        $queueStatus = array();
        while ($msg->peek() !== null) {
            $action = $msg->shift();
            $queueStatus[$action] = array(
                'action'    => $action,
                'queue'     => $msg->shift(),
                'busy'      => $msg->shift(),
                'available' => $msg->shift()
            );
        }

        return new self($queueStatus);
    }
980240
public function parseServerFinalMessage($msg)
    {
        foreach (explode(',', $msg) as $val) {
            list($attr, $aval) = array_map('trim', explode('=', $val, 2));

            switch ($attr) {
            case 'e':
                return false;

            case 'v':
                return (base64_decode($aval) === $this->_serversig);
            }
        }

        return false;
    }
765016
public function fail($msg = 'Service Error', $status = 500)
    {
        if (is_string($msg)) {
            $messages = $this->standardMessage($msg);
        } else {
            $messages = $msg;
        }

        $reData = [
            'code'     => count($messages),
            'messages' => $messages,
        ];

        //打上Log
        Log::error('Service Error', $reData);

        return response()->json($reData, $status);
    }
947105
public static function success($msg)
        {
            // $msg    = 'Success: ' . $msg;
            $space  = strlen($msg) + 4;

            $out    = self::colorize(
                str_pad(' ', $space), Console::FG_WHITE, Console::AT_BOLD, Console::BG_GREEN
            );

            $out .= PHP_EOL;

            $out .= self::colorize(
                '  ' . $msg . '  ', Console::FG_WHITE, Console::AT_BOLD, Console::BG_GREEN
            );

            $out .= PHP_EOL;

            $out .= self::colorize(
                str_pad(' ', $space), Console::FG_WHITE, Console::AT_BOLD, Console::BG_GREEN
            );

            $out .= PHP_EOL;

            return $out;
        }
134814
public static function warningLine($msg)
        {
            return self::colorize($msg, Console::FG_RED, Console::AT_BOLD) . PHP_EOL . PHP_EOL;
        }
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);
    }