@param string $messageClass
@param object $message

@return IncomingLogicalMessage
510875
private function create($messageClass, $message)
    {
        $interfaces = array_values(class_implements($messageClass, true));
        return new IncomingLogicalMessage($message, $messageClass, $interfaces);
    }
1043772
public function fromMessage($message)
    {
        static $parser;
        if (!$parser) {
            $parser = new MessageParser();
        }

        // Parse a response
        if (strtoupper(substr($message, 0, 4)) == 'HTTP') {
            $data = $parser->parseResponse($message);
            return $this->createResponse(
                $data['code'],
                $data['headers'],
                $data['body'] === '' ? null : $data['body'],
                $data
            );
        }

        // Parse a request
        if (!($data = ($parser->parseRequest($message)))) {
            throw new \InvalidArgumentException('Unable to parse request');
        }

        return $this->createRequest(
            $data['method'],
            Url::buildUrl($data['request_url']),
            [
                'headers' => $data['headers'],
                'body' => $data['body'] === '' ? null : $data['body'],
                'config' => [
                    'protocol_version' => $data['protocol_version']
                ]
            ]
        );
    }
144386
private function prepareRequest(MessageInterface $message, RecipientInterface $recipient) {
        $uri = new Uri($recipient->getEndpoint());
        return Pusher::createStandardRequest($message, $recipient)->withUri($uri);
    }
1283242
public function message($message)
    {
        if(trim($message))
        {
            $msg = new stdClass();
            $msg->type = 'text';
            $msg->message = $message;
            $this->messages[] = $msg;
        }        
    }
206831
public static function decodeMessage(string $message): Message
    {
        $offset = 0;
        $header = self::decodeHeader($message, $offset);
        $messageObject = new Message($header);
        $messageObject->setQuestions(self::decodeResourceRecords($message, $header->getQuestionCount(), $offset, true));
        $messageObject->setAnswers(self::decodeResourceRecords($message, $header->getAnswerCount(), $offset));
        $messageObject->setAuthoritatives(self::decodeResourceRecords($message, $header->getNameServerCount(), $offset));
        $messageObject->setAdditionals(self::decodeResourceRecords($message, $header->getAdditionalRecordsCount(), $offset));

        return $messageObject;
    }
135055
public function setMessage(
        $message,
        $messageType = ValidationResult::TYPE_ERROR,
        $messageCast = ValidationResult::CAST_TEXT
    ) {
        if (!in_array($messageCast, [ValidationResult::CAST_TEXT, ValidationResult::CAST_HTML])) {
            throw new InvalidArgumentException("Invalid message cast type");
        }
        $this->message = $message;
        $this->messageType = $messageType;
        $this->messageCast = $messageCast;
        return $this;
    }
614966
private function getReplyToAddressFromIncomingMessage(IncomingPhysicalMessage $incomingPhysicalMessage = null)
    {
        if (!$incomingPhysicalMessage) {
            throw new RoutingException(
                "No incoming message found, replies are only valid to call from a message handler."
            );
        }

        $replyToAddress = $incomingPhysicalMessage->getReplyToAddress();
        if ($replyToAddress === null || $replyToAddress === '') {
            $messageType = $incomingPhysicalMessage->getHeaders()[HeaderTypeEnum::ENCLOSED_CLASS];
            throw new RoutingException("No 'ReplyToAddress' found on the '$messageType' being processed");
        }

        return $incomingPhysicalMessage->getReplyToAddress();
    }
1113525
protected function getResponse(IncomingMessage $message)
    {
        $response = $this->http->post($this->apiUrl, [], [
            'query' => [$message->getText()],
            'sessionId' => md5($message->getConversationIdentifier()),
            'lang' => $this->lang,
        ], [
            'Authorization: Bearer '.$this->token,
            'Content-Type: application/json; charset=utf-8',
        ], true);

        $this->response = json_decode($response->getContent());

        return $this->response;
    }
270541
public function autoReply($messageClass = null) {
		if($messageClass) {
			return ($message = static::findOne($messageClass::reply($this->id))) && $message->pid == $this->id ? $message->replyFormat : null;
		}

		$reply = [];
		switch($this->msg_type) {
			case 'text':
				$reply = WechatMessageRule::keywords($this->appid, $this->content);
				break;
			case 'event':
				switch($this->event) {
					case 'unsubscribe':
						break;
					case 'subscribe':
						$reply = WechatMessageRule::beAdded($this->appid);
						break;
				}
				break;
		}

		if($reply) {
			$message = new static;
			foreach($reply as $k => $v) {
				$message[$k] = $v;
			}
			$message->appid = $this->appid;
			$message->type = 2;
			$message->pid = $this->id;
			$message->to_user_name = $this->from_user_name;
			$message->from_user_name = $this->to_user_name;
			if($message->save()) {
				return $message->replyFormat;
			}
		}

		return null;
	}
32374
public static function forMessage(Message $message)
    {
        $exception = new static('Missing publisher for message of class ' . get_class($message));
        $exception->tacticianMessage = $message;

        return $exception;
    }
531568
public function sendMessage(string $message) : ?Message 
    {
        $thread = $this->messageGroup();

        if ($thread === null) return null;

        return $thread->sendMessage($message);
    }
55259
public function setMessage(\Sopinet\ChatBundle\Entity\Message $message = null)
    {
        $this->message = $message;

        return $this;
    }
868464
public function withMessage(string $message): PayloadInterface
    {
        if ($this->message === $message) {
            return $this;
        }

        $clone = clone $this;
        $clone->message = $message;

        return $clone;
    }
1175663
protected function dispatch(IncomingMessage $message)
    {
        foreach ($this->eventListeners as $data) {
            $listener = $data[0];
            $predicate = $data[1];
            if (is_callable($predicate) && !call_user_func($predicate, $message)) {
                continue;
            }
            if ($listener instanceof \Closure) {
                $listener($message);
            } elseif (is_array($listener)) {
                $listener[0]->{$listener[1]}($message);
            } else {
                $listener->handle($message);
            }
        }
    }
678043
public function send($mobile, $message, $messageId = null) {
    // Create message
    $message = $this->createMessage([
      'id'      => $messageId,
      'mobile'  => $mobile,
      'message' => $message,
    ]);
    // Return sender response
    return Loader::sender($this->config)->send($message);
  }
598894
public function serialize(MessageInterface $message)
    {
        $this->class = get_class($message);

        return $this->serializer->serialize($message, 'json');
    }
359013
public static function fromMessage(Message $msg)
    {
        return new self($msg->shift(), $msg->shift(), $msg->toArray());
    }