cocos2d-x  3.0alpha1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HttpRequest Class Reference

defines the object which users must packed for HttpClient::send(HttpRequest*) method. More...

#include <HttpRequest.h>

Inheritance diagram for HttpRequest:
Object

Classes

class  _prxy
 

Public Types

enum  Type {
  GET, POST, PUT, DELETE,
  UNKNOWN
}
 Use this enum type as param in setReqeustType(param) More...
 

Public Member Functions

 HttpRequest ()
 Constructor Because HttpRequest object will be used between UI thead and network thread, requestObj->autorelease() is forbidden to avoid crashes in AutoreleasePool new/retain/release still works, which means you need to release it manually Please refer to HttpRequestTest.cpp to find its usage. More...
 
virtual ~HttpRequest ()
 Destructor. More...
 
local ~HttpRequest ()
 Destructor. More...
 
cocos2d::Objectautorelease (void)
 Override autorelease method to avoid developers to call it. More...
 
var autorelease ()
 Override autorelease method to avoid developers to call it. More...
 
void setRequestType (Type type)
 Required field for HttpRequest object before being sent. More...
 
Type getRequestType ()
 Get back the kHttpGet/Post/... More...
 
void setUrl (const char *url)
 Required field for HttpRequest object before being sent. More...
 
const char * getUrl ()
 Get back the setted url. More...
 
var getUrl ()
 Get back the setted url. More...
 
local getUrl ()
 Get back the setted url. More...
 
void setRequestData (const char *buffer, unsigned int len)
 Option field. More...
 
local setRequestData ( local buffer, local len)
 Option field. More...
 
char * getRequestData ()
 Get the request data pointer back. More...
 
int getRequestDataSize ()
 Get the size of request data back. More...
 
var getRequestDataSize ()
 Get the size of request data back. More...
 
local getRequestDataSize ()
 Get the size of request data back. More...
 
void setTag (const char *tag)
 Option field. More...
 
const char * getTag ()
 Get the string tag back to identify the request. More...
 
var getTag ()
 Get the string tag back to identify the request. More...
 
local getTag ()
 Get the string tag back to identify the request. More...
 
void setUserData (void *pUserData)
 Option field. More...
 
var setUserData ( var pUserData)
 Option field. More...
 
local setUserData ( local pUserData)
 Option field. More...
 
void * getUserData ()
 Get the pre-setted custom data pointer back. More...
 
CC_DEPRECATED_ATTRIBUTE void setResponseCallback (cocos2d::Object *pTarget, cocos2d::SEL_CallFuncND pSelector)
 Required field. More...
 
local setResponseCallback ( local pTarget, local pSelector)
 Required field. More...
 
void setResponseCallback (cocos2d::Object *pTarget, SEL_HttpResponse pSelector)
var setResponseCallback ( var pTarget, var pSelector)
local setResponseCallback ( local pTarget, local pSelector)
cocos2d::ObjectgetTarget ()
 Get the target of callback selector funtion, mainly used by HttpClient. More...
 
_prxy getSelector ()
 Get the selector function pointer, mainly used by HttpClient. More...
 
void setHeaders (std::vector< std::string > pHeaders)
 Set any custom headers. More...
 
local setHeaders ( local pHeaders)
 Set any custom headers. More...
 
std::vector< std::string > getHeaders ()
 Get custom headers. More...
 
local getHeaders ()
 Get custom headers. More...
 
- Public Member Functions inherited from Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
void release ()
 Release the ownership immediately. More...
 
void retain ()
 Retains the ownership. More...
 
Objectautorelease ()
 Release the ownership sometime soon automatically. More...
 
bool isSingleReference () const
 Returns a boolean value that indicates whether there is only one reference to the object. More...
 
unsigned int retainCount () const
 Returns the object's current reference count. More...
 
virtual bool isEqual (const Object *object)
 Returns a boolean value that indicates whether this object and a given object are equal. More...
 
virtual void acceptVisitor (DataVisitor &visitor)
virtual void update (float dt)

Protected Attributes

Type _requestType
std::string _url
 kHttpRequestGet, kHttpRequestPost or other enums More...
 
var _url
 kHttpRequestGet, kHttpRequestPost or other enums More...
 
local _url
 kHttpRequestGet, kHttpRequestPost or other enums More...
 
std::vector< char > _requestData
 target url that this request is sent to More...
 
var _requestData
 target url that this request is sent to More...
 
local _requestData
 target url that this request is sent to More...
 
std::string _tag
 used for POST More...
 
cocos2d::Object_pTarget
 user defined tag, to identify different requests in response callback More...
 
var _pTarget
 user defined tag, to identify different requests in response callback More...
 
local _pTarget
 user defined tag, to identify different requests in response callback More...
 
SEL_HttpResponse _pSelector
 callback target of pSelector function More...
 
var _pSelector
 callback target of pSelector function More...
 
local _pSelector
 callback target of pSelector function More...
 
void * _pUserData
 callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response) More...
 
std::vector< std::string > _headers
 You can add your customed data here. More...
 
- Protected Attributes inherited from Object
unsigned int _reference
 count of references More...
 
unsigned int _autoReleaseCount
 count of autorelease More...
 

Additional Inherited Members

- Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID More...
 
int _luaID
 Lua reference id. More...
 

Detailed Description

defines the object which users must packed for HttpClient::send(HttpRequest*) method.

Please refer to samples/TestCpp/Classes/ExtensionTest/NetworkTest/HttpClientTest.cpp as a sample

Since
v2.0.2

Member Enumeration Documentation

enum Type
strong

Use this enum type as param in setReqeustType(param)

Enumerator
GET 
POST 
PUT 
DELETE 
UNKNOWN 
var Type
strong

Use this enum type as param in setReqeustType(param)

Enumerator
GET 
POST 
PUT 
DELETE 
UNKNOWN 
local Type
strong

Use this enum type as param in setReqeustType(param)

Enumerator
GET 
POST 
PUT 
DELETE 
UNKNOWN 

Constructor & Destructor Documentation

HttpRequest ( )
inline

Constructor Because HttpRequest object will be used between UI thead and network thread, requestObj->autorelease() is forbidden to avoid crashes in AutoreleasePool new/retain/release still works, which means you need to release it manually Please refer to HttpRequestTest.cpp to find its usage.

var HttpRequest ( )
inline

Constructor Because HttpRequest object will be used between UI thead and network thread, requestObj->autorelease() is forbidden to avoid crashes in AutoreleasePool new/retain/release still works, which means you need to release it manually Please refer to HttpRequestTest.cpp to find its usage.

local HttpRequest ( )
inline

Constructor Because HttpRequest object will be used between UI thead and network thread, requestObj->autorelease() is forbidden to avoid crashes in AutoreleasePool new/retain/release still works, which means you need to release it manually Please refer to HttpRequestTest.cpp to find its usage.

virtual ~HttpRequest ( )
inlinevirtual

Destructor.

var ~HttpRequest ( )
inlinevirtual

Destructor.

local ~HttpRequest ( )
inlinevirtual

Destructor.

Member Function Documentation

cocos2d::Object* autorelease ( void  )
inline

Override autorelease method to avoid developers to call it.

var autorelease (   )
inline

Override autorelease method to avoid developers to call it.

local autorelease (   )
inline

Override autorelease method to avoid developers to call it.

std::vector<std::string> getHeaders ( )
inline

Get custom headers.

var getHeaders ( )
inline

Get custom headers.

local getHeaders ( )
inline

Get custom headers.

char* getRequestData ( )
inline

Get the request data pointer back.

var getRequestData ( )
inline

Get the request data pointer back.

local getRequestData ( )
inline

Get the request data pointer back.

int getRequestDataSize ( )
inline

Get the size of request data back.

var getRequestDataSize ( )
inline

Get the size of request data back.

local getRequestDataSize ( )
inline

Get the size of request data back.

Type getRequestType ( )
inline

Get back the kHttpGet/Post/...

enum value

var getRequestType ( )
inline

Get back the kHttpGet/Post/...

enum value

local getRequestType ( )
inline

Get back the kHttpGet/Post/...

enum value

_prxy getSelector ( )
inline

Get the selector function pointer, mainly used by HttpClient.

var getSelector ( )
inline

Get the selector function pointer, mainly used by HttpClient.

local getSelector ( )
inline

Get the selector function pointer, mainly used by HttpClient.

const char* getTag ( )
inline

Get the string tag back to identify the request.

The best practice is to use it in your MyClass::onMyHttpRequestCompleted(sender, HttpResponse*) callback

var getTag ( )
inline

Get the string tag back to identify the request.

The best practice is to use it in your MyClass::onMyHttpRequestCompleted(sender, HttpResponse*) callback

local getTag ( )
inline

Get the string tag back to identify the request.

The best practice is to use it in your MyClass::onMyHttpRequestCompleted(sender, HttpResponse*) callback

cocos2d::Object* getTarget ( )
inline

Get the target of callback selector funtion, mainly used by HttpClient.

var getTarget ( )
inline

Get the target of callback selector funtion, mainly used by HttpClient.

local getTarget ( )
inline

Get the target of callback selector funtion, mainly used by HttpClient.

const char* getUrl ( )
inline

Get back the setted url.

var getUrl ( )
inline

Get back the setted url.

local getUrl ( )
inline

Get back the setted url.

void* getUserData ( )
inline

Get the pre-setted custom data pointer back.

Don't forget to delete it. HttpClient/HttpResponse/HttpRequest will do nothing with this pointer

var getUserData ( )
inline

Get the pre-setted custom data pointer back.

Don't forget to delete it. HttpClient/HttpResponse/HttpRequest will do nothing with this pointer

local getUserData ( )
inline

Get the pre-setted custom data pointer back.

Don't forget to delete it. HttpClient/HttpResponse/HttpRequest will do nothing with this pointer

void setHeaders ( std::vector< std::string >  pHeaders)
inline

Set any custom headers.

var setHeaders ( var  pHeaders)
inline

Set any custom headers.

local setHeaders ( local  pHeaders)
inline

Set any custom headers.

void setRequestData ( const char *  buffer,
unsigned int  len 
)
inline

Option field.

You can set your post data here

var setRequestData ( var  buffer,
var  len 
)
inline

Option field.

You can set your post data here

local setRequestData ( local  buffer,
local  len 
)
inline

Option field.

You can set your post data here

void setRequestType ( Type  type)
inline

Required field for HttpRequest object before being sent.

kHttpGet & kHttpPost is currently supported

var setRequestType ( var  type)
inline

Required field for HttpRequest object before being sent.

kHttpGet & kHttpPost is currently supported

local setRequestType ( local  type)
inline

Required field for HttpRequest object before being sent.

kHttpGet & kHttpPost is currently supported

CC_DEPRECATED_ATTRIBUTE void
setResponseCallback
( cocos2d::Object pTarget,
cocos2d::SEL_CallFuncND  pSelector 
)
inline

Required field.

You should set the callback selector function at ack the http request completed

var setResponseCallback ( var  pTarget,
var  pSelector 
)
inline

Required field.

You should set the callback selector function at ack the http request completed

local setResponseCallback ( local  pTarget,
local  pSelector 
)
inline

Required field.

You should set the callback selector function at ack the http request completed

void setResponseCallback ( cocos2d::Object pTarget,
SEL_HttpResponse  pSelector 
)
inline
var setResponseCallback ( var  pTarget,
var  pSelector 
)
inline
local setResponseCallback ( local  pTarget,
local  pSelector 
)
inline
void setTag ( const char *  tag)
inline

Option field.

You can set a string tag to identify your request, this tag can be found in HttpResponse->getHttpRequest->getTag()

var setTag ( var  tag)
inline

Option field.

You can set a string tag to identify your request, this tag can be found in HttpResponse->getHttpRequest->getTag()

local setTag ( local  tag)
inline

Option field.

You can set a string tag to identify your request, this tag can be found in HttpResponse->getHttpRequest->getTag()

void setUrl ( const char *  url)
inline

Required field for HttpRequest object before being sent.

var setUrl ( var  url)
inline

Required field for HttpRequest object before being sent.

local setUrl ( local  url)
inline

Required field for HttpRequest object before being sent.

void setUserData ( void *  pUserData)
inline

Option field.

You can attach a customed data in each request, and get it back in response callback. But you need to new/delete the data pointer manully

var setUserData ( var  pUserData)
inline

Option field.

You can attach a customed data in each request, and get it back in response callback. But you need to new/delete the data pointer manully

local setUserData ( local  pUserData)
inline

Option field.

You can attach a customed data in each request, and get it back in response callback. But you need to new/delete the data pointer manully

Member Data Documentation

std::vector<std::string> _headers
protected

You can add your customed data here.

var _headers
protected

You can add your customed data here.

local _headers
protected

You can add your customed data here.

SEL_HttpResponse _pSelector
protected

callback target of pSelector function

var _pSelector
protected

callback target of pSelector function

local _pSelector
protected

callback target of pSelector function

cocos2d::Object* _pTarget
protected

user defined tag, to identify different requests in response callback

var _pTarget
protected

user defined tag, to identify different requests in response callback

local _pTarget
protected

user defined tag, to identify different requests in response callback

void* _pUserData
protected

callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response)

var _pUserData
protected

callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response)

local _pUserData
protected

callback function, e.g. MyLayer::onHttpResponse(HttpClient *sender, HttpResponse * response)

std::vector<char> _requestData
protected

target url that this request is sent to

var _requestData
protected

target url that this request is sent to

local _requestData
protected

target url that this request is sent to

Type _requestType
protected
var _requestType
protected
local _requestType
protected
std::string _tag
protected

used for POST

var _tag
protected

used for POST

local _tag
protected

used for POST

std::string _url
protected

kHttpRequestGet, kHttpRequestPost or other enums

var _url
protected

kHttpRequestGet, kHttpRequestPost or other enums

local _url
protected

kHttpRequestGet, kHttpRequestPost or other enums


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