Cocos2d-x  v3.8
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
HttpClient Class Reference

Singleton that handles asynchrounous http requests. More...

Public Member Functions

void enableCookies (const char *cookieFile)
 Enable cookie support. More...
 
const std::string & getCookieFilename ()
 Get the cookie filename. More...
 
void setSSLVerification (const std::string &caFile)
 Set root certificate path for SSL verification. More...
 
const std::string & getSSLVerification ()
 Get ths ssl CA filename. More...
 
void send (HttpRequest *request)
 Add a get request to task queue. More...
 
void sendImmediate (HttpRequest *request)
 Immediate send a request. More...
 
void setTimeoutForConnect (int value)
 Set the timeout value for connecting. More...
 
int getTimeoutForConnect ()
 Get the timeout value for connecting. More...
 
void setTimeoutForRead (int value)
 Set the timeout value for reading. More...
 
int getTimeoutForRead ()
 Get the timeout value for reading. More...
 

Static Public Member Functions

static HttpClientgetInstance ()
 Get instance of HttpClient. More...
 
static void destroyInstance ()
 Relase the instance of HttpClient.
 

Static Public Attributes

static const int RESPONSE_BUFFER_SIZE = 256
 The buffer size of _responseMessage.
 

Detailed Description

Singleton that handles asynchrounous http requests.

Once the request completed, a callback will issued in main thread when it provided during make request.

Member Function Documentation

static HttpClient* getInstance ( )
static

Get instance of HttpClient.

Returns
the instance of HttpClient.
void enableCookies ( const char *  cookieFile)

Enable cookie support.

Parameters
cookieFilethe filepath of cookie file.
const std::string&
getCookieFilename
( )

Get the cookie filename.

Returns
the cookie filename
void setSSLVerification ( const std::string &  caFile)

Set root certificate path for SSL verification.

Parameters
caFilea full path of root certificate.if it is empty, SSL verification is disabled.
const std::string&
getSSLVerification
( )

Get ths ssl CA filename.

Returns
the ssl CA filename
void send ( HttpRequest request)

Add a get request to task queue.

Parameters
requesta HttpRequest object, which includes url, response callback etc. please make sure request->_requestData is clear before calling "send" here.
void sendImmediate ( HttpRequest request)

Immediate send a request.

Parameters
requesta HttpRequest object, which includes url, response callback etc. please make sure request->_requestData is clear before calling "sendImmediate" here.
void setTimeoutForConnect ( int  value)

Set the timeout value for connecting.

Parameters
valuethe timeout value for connecting.
int getTimeoutForConnect ( )

Get the timeout value for connecting.

Returns
int the timeout value for connecting.
void setTimeoutForRead ( int  value)

Set the timeout value for reading.

Parameters
valuethe timeout value for reading.
int getTimeoutForRead ( )

Get the timeout value for reading.

Returns
int the timeout value for reading.

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