发送消息
@param SendGroupMessageRequest $request
@return BaseResponse
@throws Exception\TIMException
344773
public function sendMessage(SendGroupMessageRequest $request)
    {
        $response = new SendGroupMessageResponse();
        return $this->client->sendRequest($request, $response);
    }
431233
private function dispatchRequest($request)
    {
        // track the number of requests across instances
        self::$requestCount++;
        $timestart = microtime(true);

        $response = self::transport()->send($request);

        // pass the response through the filter chain
        foreach ($this->filters as $filter) {
            $response = $filter->response($response);
        }

        $httpCode = $response->getStatus()->getCode();
        $location = $response->getHeaders()->value('Location');
        $body = $response->getBody();

        // track the time taken across instances
        self::$requestTime += microtime(true) - $timestart;

        // process a redirect if needed
        if ($httpCode < 400 && $location) {
            return $this->redirect($location);
        } else {
            $this->redirects = 0;
        }

        // translate error code to a typed exception
        if ($httpCode == 500) {
            throw new Error\InternalServerError($body);
        } elseif ($httpCode == 400) {
            throw new Error\BadRequest($body);
        } elseif ($httpCode == 401) {
            throw new Error\Unauthorized($body);
        } elseif ($httpCode == 404) {
            throw new Error\NotFound($body);
        } elseif ($httpCode >= 300) {
            throw new Error($body, $httpCode);
        }

        return $response;
    }
311673
public function sendRequest(OAuthRequest $request)
    {
        switch ($request->getMethod()) {
            case OAuthRequest::METHOD_GET:
                $httpResponse = $this->httpAdapter->getContent($request->getUrl(), $request->getHeaders());
                break;

            case OAuthRequest::METHOD_POST:
                $postParameters = array();
                foreach ($request->getPostParameters() as $name => $value) {
                    $postParameters[rawurldecode($name)] = rawurldecode($value);
                }

                $httpResponse = $this->httpAdapter->postContent(
                    $request->getUrl(),
                    $request->getHeaders(),
                    $postParameters,
                    $request->getFileParameters()
                );
                break;

            default:
                throw new \RuntimeException(sprintf(
                    'The request method "%s" is not supported.',
                    $request->getMethod()
                ));
        }

        $response = new OAuthResponse($httpResponse, $request->getResponseFormat());

        if (!$response->isValid()) {
            throw new OAuthException('The http response is not valid.', $response);
        }

        return $response;
    }
349853
public function send(Request $request)
    {
        $response   = new GetIndexResponse();
        $rpbGetReq  = $this->createRpbMessage($request);
        $rpbGetResp = $this->client->send($rpbGetReq, RiakMessageCodes::YOKOZUNA_INDEX_GET_REQ, RiakMessageCodes::YOKOZUNA_INDEX_GET_RESP);

        if ( ! $rpbGetResp instanceof RpbYokozunaIndexGetResp) {
            return $response;
        }

        if ( ! $rpbGetResp->hasIndex()) {
            return $response;
        }

        $rpbIndex = is_array($rpbGetResp->index)
            ? reset($rpbGetResp->index)
            : $rpbGetResp->index;

        $response->nVal   = $rpbIndex->n_val;
        $response->name   = $rpbIndex->name;
        $response->schema = $rpbIndex->schema;

        return $response;
    }
231355
protected function doSendRequest(Request $request): Response
    {
        if (!$this->shouldUseGearman()) {
            return $this->locator->getRequestBus()->receiveRequest($request);
        }

        $envelope = new TransportEnvelope($request, 'php');
        $channel = $this->router->forRequest($request);

        try {
            $client = $this->getClient();
            $result = @$client->doNormal($channel, $envelope->toString(), (string)$request->get('request_id'));
            $this->validateReturnCode($client, $channel);
            return TransportEnvelope::fromString($result)->getMessage();
        } catch (\GearmanException $ge) {
            if (isset(self::$reconnectCodes[$ge->getCode()])) {
                $this->destroyClient();
                return $this->locator->getRequestBus()->receiveRequest($request);
            }

            throw $ge;
        } catch (\Throwable $e) {
            throw $e;
        }
    }
507450
protected function _send(Request $request)
    {
        $deadline = false;
        if (isset($this->_contextOptions['timeout']) && $this->_contextOptions['timeout'] > 0) {
            $deadline = time() + $this->_contextOptions['timeout'];
        }

        $url = $request->getUri();
        $this->_open($url);
        $content = '';
        $timedOut = false;

        while (!feof($this->_stream)) {
            if ($deadline !== false) {
                stream_set_timeout($this->_stream, max($deadline - time(), 1));
            }

            $content .= fread($this->_stream, 8192);

            $meta = stream_get_meta_data($this->_stream);
            if ($meta['timed_out'] || ($deadline !== false && time() > $deadline)) {
                $timedOut = true;
                break;
            }
        }
        $meta = stream_get_meta_data($this->_stream);
        fclose($this->_stream);

        if ($timedOut) {
            throw new HttpException('Connection timed out ' . $url, 504);
        }

        $headers = $meta['wrapper_data'];
        if (isset($headers['headers']) && is_array($headers['headers'])) {
            $headers = $headers['headers'];
        }

        return $this->createResponses($headers, $content);
    }
71225
private function _dispatchRequest($request)
	{
		// track the number of requests across instances
		self::$requestCount++;
		$timestart = microtime(true);

		$response = self::transport()->send($request);

		// pass the response through the filter chain
		foreach($this->_filters as $filter)
		{
			$response = $filter->response($response);
		}

		$httpCode = $response->getStatus()->getCode();
		$location = $response->getHeaders()->value('Location');
		$body = $response->getBody();

		// track the time taken across instances
		self::$requestTime += microtime(true) - $timestart;

		// process a redirect if needed
		if($httpCode < 400 && $location)
		{
			return $this->_redirect($location);
		}
		else
		{
			$this->_redirects = 0;
		}

		// translate error code to a typed exception
		if($httpCode == 500)
		{
			throw new Error\InternalServerError($body);
		}
		elseif($httpCode == 400)
		{
			throw new Error\BadRequest($body);
		}
		elseif($httpCode == 401)
		{
			throw new Error\Unauthorized($body);
		}
		elseif($httpCode == 404)
		{
			throw new Error\NotFound($body);
		}
		else if($httpCode >= 300)
		{
			throw new Error($body,$httpCode);
		}

		return $response;
	}
1012516
public function getMessageHistory($chatType, $time)
    {
        $request = new GetMessageHistoryRequest($chatType, $time);
        $response = new BaseResponse();
        return $this->client->sendRequest($request, $response);
    }
259354
private function runBackendTree(Request $request)
    {
        if (null === ($request->query->get('picker'))) {
            throw new \InvalidArgumentException('No picker was given here.');
        }
        $picker = $this->container->get('contao.picker.builder')->createFromData($request->query->get('picker'));

        $this->container->get('contao.framework')->getAdapter(\Contao\Controller::class)->setStaticUrls();

        $treeSelector = $this->prepareTreeSelector($picker);

        $sessionBag = $this->container->get('session')->getBag('contao_backend');
        $sessionBag->set($treeSelector->getSearchSessionKey(), $picker->getConfig()->getValue());

        $template = new ContaoBackendViewTemplate('be_main');
        $template
            ->set('isPopup', true)
            ->set('main', $treeSelector->generatePopup())
            ->set('theme', Backend::getTheme())
            ->set('base', Environment::get('base'))
            ->set('language', $GLOBALS['TL_LANGUAGE'])
            ->set('title', StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['treepicker']))
            ->set('charset', $GLOBALS['TL_CONFIG']['characterSet'])
            ->set('addSearch', $treeSelector->searchField)
            ->set('search', $GLOBALS['TL_LANG']['MSC']['search'])
            ->set('action', \ampersand($request->getUri()))
            ->set('value', $sessionBag->get($treeSelector->getSearchSessionKey()))
            ->set('manager', $GLOBALS['TL_LANG']['MSC']['treepickerManager'])
            ->set('breadcrumb', $GLOBALS['TL_DCA'][$treeSelector->foreignTable]['list']['sorting']['breadcrumb']);

        return $template->getResponse();
    }
668144
public function callbackAction(Request $request): Response
    {
        /** @var LoggerInterface $logger */
        $logger = $this->get('logger');
        /** @var EventDispatcherInterface $dispatcher */
        $dispatcher = $this->get('event_dispatcher');

        // get the body from the request
        $content = $request->getContent();

        // decode the request object to see what kind of object this is
        $json = json_decode($content, true) ?? [];
        if (!\array_key_exists(self::NOTIFICATION_URL, $json)) {
            throw new HttpException(400, self::BAD_REQUEST);
        }

        // serialize into json and feed it to the api components
        $notificationStr = json_encode($json[self::NOTIFICATION_URL]);
        $notification = NotificationUrl::createFromJsonString($notificationStr);

        // if this is not a mutation, don't accept it
        if (self::MUTATION !== $notification->getCategory()) {
            throw new HttpException(405, self::WRONG_REQUEST_TYPE);
        }

        // if the mutation doesn't hold a payment, don't accept it
        $payment = $notification->getObject()->getPayment();
        if (null === $payment) {
            throw new HttpException(400, self::PAYMENT_MISSING_FROM_REQUEST);
        }

        // logging for historical reasons
        $logger->info(
            sprintf(
                self::RECEIVED_PAYMENT_OBJECT_FROM_BUNQ_FOR_ACCOUNT_ID,
                $payment->getMonetaryAccountId()
            ),
            [
                'monetaryAccountId' => $payment->getMonetaryAccountId(),
                'amount' => $payment->getAmount()->getValue(),
                'currency' => $payment->getAmount()->getCurrency(),
                'description' => $payment->getDescription(),
                'counter_party_iban' => $payment->getCounterpartyAlias()->getIban(),
                'counter_party_name' => $payment->getCounterpartyAlias()->getDisplayName(),
            ]
        );

        // create the event and dispatch it into the kernel
        $event = new MutationEvent($payment);
        $dispatcher->dispatch(MutationEvent::NAME, $event);

        // tell bunq we're cool
        return new Response(self::CALLBACK_OK, 200);
    }
130262
public function sendAction(Request $request)
    {
        if ($request->getMethod() == 'POST') {
            $message = new Message();
            $message->setSender($this->getUser());
            $message->setReceiver($this->findUser($request->get('receiver')));
            $message->setSubject($request->get('subject'));
            $message->setContent($request->get('content'));
            $message->setInsertDate(new \DateTime());
            $message->setIsRead(false);
            $this->get('doctrine.orm.entity_manager')->persist($message);
            $this->get('doctrine.orm.entity_manager')->flush();

            $this->get('event_dispatcher')->dispatch(CunningsoftMessageEvents::MESSAGE_SENT, new MessageEvent($message));
            $this->container->get('session')->setFlash('cunningsoft_message_success', 'message.flash.sent');

            return $this->redirect($this->generateURL('cunningsoft_message_list'));
        }

        return array(
            'users' => $this->findAllUsers(),
        );
    }
80099
public function sendRequest($request)
    {
        try {
            $result = fputs($this->_socket, $request."\r\n");
        } catch (\Exception $e) {

        }

        if (!$result) {
            throw new \RuntimeException('send failed - connection closed?'.$e->getMessage());
        }
    }
822522
public function sendRequest(Request $request)
    {
        try {
            $rawResponse = $this->processRequest($request);
        } catch (Exception $exception) {
            if ($this->successor) {
                return $this->successor->sendRequest($request);
            }
            throw $exception;
        }

        $response = new Response($request, $rawResponse);

        if ($response->isError()) {
            throw $response->getThrownException();
        }

        return $response;
    }
1352820
public function setGroupNoSpeaking($noSpeakingTime)
    {
        $request = new SetGroupNoSpeakingRequest($this->identifier, $noSpeakingTime);
        $response = new BaseResponse();
        return $this->client->sendRequest($request, $response);
    }
1059635
public function createGroupAsync(CreateGroupRequest $request, AsyncCallback $callback = null)
    {
        $response = new CreateGroupResponse();
        return $this->client->sendRequestAsync($request, $response, $callback);
    }
560714
public function store(TimeslotCreateRequest $request)
    {
        try {
            $this->validator->with($request->all())->passesOrFail(ValidatorInterface::RULE_CREATE);

            $timeslot = $this->repository->create($request->all());

            $response = [
                'message' => 'Timeslot created.',
                'data'    => $timeslot->toArray(),
            ];

            if ($request->wantsJson()) {
                return response()->json($response);
            }

            return redirect()->back()->with('message', $response['message']);
        } catch (ValidatorException $e) {
            if ($request->wantsJson()) {
                return response()->json([
                    'error'   => true,
                    'message' => $e->getMessageBag()
                ]);
            }

            return redirect()->back()->withErrors($e->getMessageBag())->withInput();
        }
    }
1343644
public function send(Request $request) {
        $method   = strtolower($request->getMethod());
        $response = $method === HttpMethods::GET || $method === HttpMethods::DELETE ? $this->restClient->$method($request->getUrlAndQuery(), $request->getCurlOptions()) : $this->restClient->$method($request->getUrlAndQuery(), $request->getPayload(), $request->getCurlOptions());

        try {
            return $request->isExpectedStatusCode($response->getStatusCode()) ? $response : Exceptions::RequestFailedException($request, $response->getStatusCode(), $response->getContent());
        } catch (DBALException\DriverException $e) {
            $responseExceptionFactory = new ResponseExceptionFactory();
            throw $responseExceptionFactory->createDbalException($response, $e);
        }
    }