Sends an image reply.

@param Type\Image $message

@throws Exception\AlreadySentException
345677
public function sendImage (Type\Image $message)
    {
        $this->sendReply(
            $this->buildMessage(
                [
                    'MsgType' => $message->getType(),
                    ucfirst($message->getType()) => [
                        'MediaId' => $message->getMediaID(),
                    ],
                ]
            )
        );
    }
965809
public function send($message)
    {
        try {
            $code = 200;
            $this->sendEvent($this->targetServiceName, $message);
            $message = 'Event has been sent';
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $code = $exception->getCode();
        }

        return new Response(
            json_encode(['message' => $message]),
            (!empty($code)) ? $code : 500
        );
    }
178840
public function serverResponse()
    {
        if(!empty($_GET['imageQuery']))
        {
            $picture  = $this->loadPicture($_GET['imageQuery']);
            $savePath = $this->getPath($picture);

            $picture->save($savePath);

            if($savePath !== $this->getPath($picture))
            {
                throw new Exception('Picture effect is changing its own arguments on effect apply');
            }

            $picture->output();
        }

        if(!empty($_POST['regenerate']))
        {
            $picture = $this->loadPicture($_POST['regenerate']);
            $picture->save($this->getPath($picture));
        }
    }
1148408
private function initImage($image)
    {
        if(is_string($image))
        {
            return new Imagick($image);
        }
        elseif ($image instanceof Imagick)
        {
            return $image;
        }
        else
        {
            throw new Exception('Image input must be Imagick object or string path ('.gettype($image).' sent)');
        }
    }
338520
private function _send($message)
    {
        // Errors come from HTTPException. This helps set the proper envelope data
        /** @var Response $response */
        $response = $this->di->get('response');
        $response->setStatusCode($this->httpCode, $this->httpMessage);

        // HEAD does everything exactly the same as GET, but contains no body
        // empty responses (such as a 204 result) should also skip JSON configuration
        if ($this->head || !$message) {
            $response->setContentType(null); //forces content-type to not be sent
        } else {
            $jsonConfig = $this->di->get('config')['application']['debugApp'] ? JSON_PRETTY_PRINT : 0;
            $response->setJsonContent($message, $jsonConfig);
        }

        $response->send();
    }
165140
protected function sendSwiftMessage($message)
    {
        if ($this->events) {
            $this->events->dispatch('mailer.sending', array($message));
        }

        if (! $this->pretending) {
            try {
                $this->swift->send($message, $this->failedRecipients);
            }
            finally {
                $this->swift->getTransport()->stop();
            }
        }

        // In the pretending mode.
        else if (isset($this->logger)) {
            $this->logMessage($message);
        }
    }
215691
private function throwBadRequest($message, $metadata = [], array $headers = [])
    {
        throw new HttpResponseException($this->badRequestResponse($message, $metadata, $headers));
    }
144053
public function sendMessage(RequestMessage $message)
    {
        if ($message instanceof FriendMessage) {
            $request = new Request\SendFriendMessageRequest($message, $this->getCredential());
        } elseif ($message instanceof GroupMessage) {
            $request = new Request\SendGroupMessageRequest($message, $this->getCredential());
        } else {
            $request = new Request\SendDiscusMessageRequest($message, $this->getCredential());
        }
        $response = $this->sendRequest($request);

        return Request\SendMessageRequest::parseResponse($response);
    }
92726
protected function sendSwiftMessage( $message )
	{
		Hooks::trigger( 'mailer.sending', compact( $message ) );

		try
		{
			$this->swift->send( $message, $this->failedRecipients );
		}
		finally
		{
			$this->swift->getTransport()->stop();
		}
	}
581545
public function sendMessageToBrowser($message)
    {
        if (!$this->outputStarted) {
            ob_start();
            echo '<!DOCTYPE html><html lang="en"><head></head><body>';
            $this->outputStarted = true;
        }

        echo strip_tags($message, '<h1><p><br><hr>');
        echo '<br />';
        echo str_repeat(" ", 6024), "\n";
        ob_flush();
        flush();
    }
855098
public function send(Mail\Message $message)
    {
        $this->getMandrillClient();

        $body = $message->getBody();
        $attachments = [];

        switch (true) {
            case $body instanceof Message:
                $bodyHtml = $this->getHtmlPart($body);
                $bodyText = $this->getTextPart($body);
                $attachments = $this->getAttachments($body);
                break;
            case is_string($body):
                $bodyHtml = $body;
                $bodyText = $message->getBodyText();
                break;
            case is_object($body):
                $bodyHtml = $body->__toString();
                $bodyText = $message->getBodyText();
                break;
            default:
                throw new Exception\InvalidArgumentException(
                    sprintf(
                        '"%s" expectes a body that is a string, an object or a Zend\Mime\Message; received "%s"',
                        __METHOD__,
                        is_object($body) ? get_class($body) : gettype($body)
                    )
                );
                break;
        }

        $message = [
            'html' => $bodyHtml,
            'text' => $bodyText,
            'subject' => $message->getSubject(),
            'from_email' => $message->getFrom()->current()->getEmail(),
            'from_name' => $message->getFrom()->current()->getName(),
            'to' => array_merge(
                $this->mapAddressListToArray($message->getTo(), 'to'),
                $this->mapAddressListToArray($message->getCc(), 'cc'),
                $this->mapAddressListToArray($message->getBcc(), 'bcc')
            ),
            'headers' => $message->getHeaders()->toArray(),
            'subaccount' => $this->options->getSubAccount(),
            'attachments' => $attachments
        ];

        return $this->mandrillClient->messages->send($message);
    }
91180
public function send(Message $message) : void
    {
        header('Content-Type: text/xml', true);

        $xml = $this->getOutputToSend($message);
        if ($xml !== false) {
            Utils::getContainer()->debugMessage($xml, 'out');
            echo $xml;
        }

        // DOMDocument::saveXML() returned false. Something is seriously wrong here. Not much we can do.
        exit(0);
    }
1321249
public void sendMessage(final String message) {
        try {
            session.sendMessage(new TextMessage(message));
        }
        catch (IOException e) {
            logger.error("[sendTextMessage]", e);
        }
    }
1199664
public function send(): void
	{
		if (count($this->recipients) === 0) {
			throw new NoRecipientException();
		}
		if ($this->loader !== null) {
			$this->latte->setLoader($this->loader);
			$body = $this->latte->renderToString($this->template, $this->variables);
		} else {
			$body = $this->latte->renderToString($this->basePath . $this->template . '.latte', $this->variables);
		}

		$this->message->setHtmlBody($body, $this->imagePath);
		$this->mailer->send($this->message);

		$this->onSend();
	}
702651
public function message($type, $message)
    {
        if ( $this->session->has('flashMessages') ) {
            $flashMessages = $this->session->get('flashMessages');
            $flashMessages[] = ['type' => $type, 'message' => $message];
            $this->session->set('flashMessages', $flashMessages);
        } else {
            $this->session->set('flashMessages', [['type' => $type, 'message' => $message]]);
        }
    }
55768
public function send($message)
    {
        try {
            $code = 200;
            $this->sendCommand($this->getTargetServiceName(), $message, false);
            $message = 'Command has been sent';
        } catch (\Exception $exception) {
            $message = $exception->getMessage();
            $code = $exception->getCode();
        }

        return new Response(
            json_encode(['message' => $message]),
            (!empty($code)) ? $code : 500
        );
    }
243465
public function send(Message $message)
    {

        if (!$this->serverApiKey) {
            throw new Exception("Server API Key not set", Exception::ILLEGAL_API_KEY);
        }

        //GCM response: Number of messages on bulk (1001) exceeds maximum allowed (1000)
        if (count($message->getRegistrationIds()) > 1000) {
            throw new Exception(
                "Malformed request: Registration Ids exceed the GCM imposed limit of 1000",
                Exception::MALFORMED_REQUEST
            );
        }

        $rawData = $this->formMessageData($message);
        $this->validatePayloadSize($rawData, 'data', 4096);
        $this->validatePayloadSize($rawData, 'notification', 2048);
        $data = json_encode($rawData);

        $headers = array(
            'Authorization: key='.$this->serverApiKey,
            'Content-Type: application/json'
        );

        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $this->gcmUrl);

        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

        if ($this->caInfoPath !== false) {
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
            curl_setopt($ch, CURLOPT_CAINFO, $this->caInfoPath);
        } else {
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        }

        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

        $resultBody = curl_exec($ch);
        $resultHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

        curl_close($ch);

        switch ($resultHttpCode) {
            case "200":
                //All fine. Continue response processing.
                break;

            case "400":
                throw new Exception('Malformed request. '.$resultBody, Exception::MALFORMED_REQUEST);
                break;

            case "401":
                throw new Exception('Authentication Error. '.$resultBody, Exception::AUTHENTICATION_ERROR);
                break;

            default:
                //TODO: Retry-after
                throw new Exception("Unknown error. ".$resultBody, Exception::UNKNOWN_ERROR);
                break;
        }

        return new Response($message, $resultBody);
    }