AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper Class Reference

#include <CurlMultiHandleWrapper.h>

Public Member Functions

 ~CurlMultiHandleWrapper ()
 
CURLM * getCurlHandle ()
 
CURLMcode addHandle (CURL *handle)
 
CURLMcode removeHandle (CURL *handle)
 
CURLMcode perform (int *runningHandles)
 
CURLMcode poll (std::chrono::milliseconds timeout, int *countHandlesUpdated)
 
bool wakeup ()
 
CURLMsg * infoRead (int *messagesInQueue)
 

Static Public Member Functions

static std::unique_ptr< CurlMultiHandleWrappercreate ()
 

Detailed Description

This class wraps a libcurl multi handle as a C++ object. Wrapping enables:

Constructor & Destructor Documentation

◆ ~CurlMultiHandleWrapper()

alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::~CurlMultiHandleWrapper ( )

Destructor.

Member Function Documentation

◆ addHandle()

CURLMcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::addHandle ( CURL *  handle)

Add a libcurl handle to this instance.

Parameters
handleThe libcurl handle to add to this instance.
Returns
libcurl code indicating the result of this operation.

◆ create()

static std::unique_ptr<CurlMultiHandleWrapper> alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::create ( )
static

Create a CurlMultiHandleWrapper.

Returns
The new CurlMultiHandleWrapper instance, or nullptr if the operation fails.

◆ getCurlHandle()

CURLM* alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::getCurlHandle ( )

Get the libcurl multi handle underlying this instance.

Returns
The libcurl multi handle underlying this instance.

◆ infoRead()

CURLMsg* alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::infoRead ( int *  messagesInQueue)

Receive the next messages about the libcurl handles added to this libcurl multi handle.

Parameters
[out]messagesInQueueThe number of libcurl handles for which messages remain.
Returns
The next message or nullptr if there are no more messages.

◆ perform()

CURLMcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::perform ( int *  runningHandles)

Read and/or write available data for the libcurl handles added to this libcurl multi handle.

Parameters
[out]runningHandlesReturns the number of handles for which read/write operations were performed.
Returns
libcurl code indicating the result of this operation.

◆ poll()

CURLMcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::poll ( std::chrono::milliseconds  timeout,
int *  countHandlesUpdated 
)

Poll for actions to perform on the libcurl handles added to this libcurl multi handle. This can waken up by the wakeup() call.

Note
For Libcurl v7.68.0 or higher, this function will call curl_multi_poll(), this allows the polling thread to be woken up by the wakeup() call. Otherwise for Libcurl v7.67.0 or lower, it will call curl_multi_wait() and the call to wakeup() will do nothing.
Parameters
timeoutHow long to wait for actions to perform.
[out]countHandlesUpdatedThe number of handles for which actions are ready to be performed.
Returns
libcurl code indicating the result of this operation.

◆ removeHandle()

CURLMcode alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::removeHandle ( CURL *  handle)

Remove a libcurl handle from this instance.

Parameters
handleThe libcurl handle to remove from this instance.
Returns
libcurl code indicating the result of this operation.

◆ wakeup()

bool alexaClientSDK::avsCommon::utils::libcurlUtils::CurlMultiHandleWrapper::wakeup ( )

This function can be called from any thread to wake up a sleeping poll().

Note
For Libcurl v7.68.0 or higher, this function will call curl_multi_wakeup(). Otherwise, this is a no-op operation.
Returns
true if the call succeeded, or false otherwise.

The documentation for this class was generated from the following file:

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0