My Project
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
ParaEngine::CNPLNetClient Class Reference

Option names. More...

#include <NPLNetClient.h>

Inheritance diagram for ParaEngine::CNPLNetClient:
ParaEngine::INPLWebServiceClient

Public Member Functions

virtual INPLWebServiceGetWebService (const char *sURL)
 get the web service interface by its URL, if the web service does not exists it will return NULL, in which case one needs to call OpenWebService()
 
virtual INPLWebServiceOpenWebService (const char *sURL, const char *sUserName, const char *sPassword, const char *sDomain)
 open a new web service with optional credentials More...
 
virtual bool CloseWebService (const char *sURL)
 close a given web service. More...
 
virtual INPLJabberClientGetJabberClient (const char *sJID)
 get an existing jabber client instance interface by its JID. More...
 
virtual INPLJabberClientCreateJabberClient (const char *sJID)
 Create a new jabber client instance with the given jabber client ID. More...
 
virtual bool CloseJabberClient (const char *sJID)
 close a given jabber client instance. More...
 
virtual void AsyncDownload (const char *url, const char *destFolder, const char *callbackScript, const char *DownloaderName)
 Asynchronously download a file from the url. More...
 
virtual void CancelDownload (const char *DownloaderName)
 cancel all asynchronous downloads that matches a certain downloader name pattern More...
 
virtual int Download (const char *url, const char *destFolder, const char *callbackScript, const char *DownloaderName)
 Synchronous call of the function AsyncDownload(). More...
 
virtual int ProcessResults ()
 this function is called once on each frame to polling all results and calling the callbacks in scripting interface More...
 
virtual int ProcessDownloaderResults ()
 this function is called once on each frame to polling all results and calling the callbacks in scripting interface More...
 
virtual void DeleteThis ()
 delete this object when it is no longer needed. More...
 
virtual bool AppendURLRequest (CURLRequestTask *pUrlTask, const char *sPoolName=NULL)
 Append URL request to a pool. More...
 
virtual bool ChangeRequestPoolSize (const char *sPoolName, int nCount)
 There is generally no limit to the number of requests sent. More...
 
virtual int ProcessUrlRequests ()
 this function is called once on each frame to polling all results and calling the callbacks in scripting interface More...
 
void AddPendingRequest (const char *sURL)
 add a string url to a set. More...
 
bool HasPendingRequest (const char *sURL)
 whether the given request is already in the pending set. More...
 
void RemovePendingRequest (const char *sURL)
 remove a string url from a set. More...
 
void ClearAllPendingRequests ()
 clear all pending request. More...
 
string GetCachePath (const char *sFileUrl)
 get the md5 of sFileUrl. More...
 
void Cleanup ()
 just clean up everything. More...
 

Static Public Member Functions

static CNPLNetClientGetInstance ()
 get a singleton instance of this class. More...
 
static void ReleaseInstance ()
 release the instance if it has not been released yet
 

Protected Member Functions

CRequestTaskPoolCreateGetRequestTaskPool (const char *sPoolName=NULL)
 get a task pool by name. More...
 

Detailed Description

Option names.

These must be well-formed XML element names.

Member Function Documentation

§ AddPendingRequest()

void ParaEngine::CNPLNetClient::AddPendingRequest ( const char *  sURL)

add a string url to a set.

this is used for tracking in processing requests. this function is called automatically when AppendURLRequest is called.

§ AppendURLRequest()

bool ParaEngine::CNPLNetClient::AppendURLRequest ( CURLRequestTask pUrlTask,
const char *  sPoolName = NULL 
)
virtual

Append URL request to a pool.

connections in the same pool are reused as much as possible. There is generally no limit to the number of requests sent. However, each pool has a specified maximum number of concurrent worker slots. the default number is 1. One can change this number with ChangeRequestPoolSize.

Parameters
pUrlTaskmust be new CURLRequestTask(), the ownership of the task is transfered to the manager. so the caller should never delete the pointer.
sPoolNamethe request pool name. If the pool does not exist, it will be created. If null, the default pool is used. there are some reserved pool names used by ParaEngine. They are:
  • "d": download pool. default size is 2, for downloading files.
  • "r": rest pool. default size is 5, for REST like HTTP get/post calls.
  • "w": web pool. default size is 5, for web based requests.

Implements ParaEngine::INPLWebServiceClient.

§ AsyncDownload()

void ParaEngine::CNPLNetClient::AsyncDownload ( const char *  url,
const char *  destFolder,
const char *  callbackScript,
const char *  DownloaderName 
)
virtual

Asynchronously download a file from the url.

Parameters
callbackScriptscript code to be called, a global variable called msg is assigned, as below msg = {DownloadState=""|"complete"|"terminated", totalFileSize=number, currentFileSize=number, PercentDone=number}

Implements ParaEngine::INPLWebServiceClient.

§ CancelDownload()

void ParaEngine::CNPLNetClient::CancelDownload ( const char *  DownloaderName)
virtual

cancel all asynchronous downloads that matches a certain downloader name pattern

Parameters
DownloaderName:regularexpression. such as "proc1", "proc1.*", ".*"

Implements ParaEngine::INPLWebServiceClient.

§ ChangeRequestPoolSize()

bool ParaEngine::CNPLNetClient::ChangeRequestPoolSize ( const char *  sPoolName,
int  nCount 
)
virtual

There is generally no limit to the number of requests sent.

However, each pool has a specified maximum number of concurrent worker slots. the default number is 1. One can change this number with this function.

Implements ParaEngine::INPLWebServiceClient.

§ Cleanup()

void ParaEngine::CNPLNetClient::Cleanup ( )

just clean up everything.

§ ClearAllPendingRequests()

void ParaEngine::CNPLNetClient::ClearAllPendingRequests ( )

clear all pending request.

§ CloseJabberClient()

bool ParaEngine::CNPLNetClient::CloseJabberClient ( const char *  sJID)
virtual

close a given jabber client instance.

Basically, there is no need to close a web service, unless one wants to reopen it with different credentials

Parameters
sJIDsuch as "lixizhi@paraweb3d.com"

Implements ParaEngine::INPLWebServiceClient.

§ CloseWebService()

bool ParaEngine::CNPLNetClient::CloseWebService ( const char *  sURL)
virtual

close a given web service.

Basically, there is no need to close a web service, unless one wants to reopen it with different credentials

Implements ParaEngine::INPLWebServiceClient.

§ CreateGetRequestTaskPool()

CRequestTaskPool * ParaEngine::CNPLNetClient::CreateGetRequestTaskPool ( const char *  sPoolName = NULL)
protected

get a task pool by name.

and create it if it does not exist.

§ CreateJabberClient()

INPLJabberClient * ParaEngine::CNPLNetClient::CreateJabberClient ( const char *  sJID)
virtual

Create a new jabber client instance with the given jabber client ID.

It does not open a connection immediately.

Parameters
sJIDsuch as "lixizhi@paraweb3d.com"

Implements ParaEngine::INPLWebServiceClient.

§ DeleteThis()

void ParaEngine::CNPLNetClient::DeleteThis ( )
virtual

delete this object when it is no longer needed.

Implements ParaEngine::INPLWebServiceClient.

§ Download()

int ParaEngine::CNPLNetClient::Download ( const char *  url,
const char *  destFolder,
const char *  callbackScript,
const char *  DownloaderName 
)
virtual

Synchronous call of the function AsyncDownload().

This function will not return until download is complete or an error occurs. this function is rarely used. AsyncDownload() is used.

Returns
:1 if succeed, 0 if fail

Implements ParaEngine::INPLWebServiceClient.

§ GetCachePath()

string ParaEngine::CNPLNetClient::GetCachePath ( const char *  sFileUrl)

get the md5 of sFileUrl.

the returned value is URLEncoded.

§ GetInstance()

CNPLNetClient * ParaEngine::CNPLNetClient::GetInstance ( )
static

get a singleton instance of this class.

§ GetJabberClient()

INPLJabberClient * ParaEngine::CNPLNetClient::GetJabberClient ( const char *  sJID)
virtual

get an existing jabber client instance interface by its JID.

If the client is not created using CreateJabberClient() before, function may return NULL.

Parameters
sJIDsuch as "lixizhi@paraweb3d.com"

Implements ParaEngine::INPLWebServiceClient.

§ HasPendingRequest()

bool ParaEngine::CNPLNetClient::HasPendingRequest ( const char *  sURL)

whether the given request is already in the pending set.

one can use this function to check whether there is a pending request due to previous call of AppendURLRequest

§ OpenWebService()

INPLWebService * ParaEngine::CNPLNetClient::OpenWebService ( const char *  sURL,
const char *  sUserName,
const char *  sPassword,
const char *  sDomain 
)
virtual

open a new web service with optional credentials

Parameters
sURLurl of the web service, such as http://paraengine.com/test.asmx
sUserNamethe user name associated with the credentials
sPasswordthe password for the user name associated with the credentials.
sDomainthe domain or computer name that verifies the credentials

Implements ParaEngine::INPLWebServiceClient.

§ ProcessDownloaderResults()

int ParaEngine::CNPLNetClient::ProcessDownloaderResults ( )
virtual

this function is called once on each frame to polling all results and calling the callbacks in scripting interface

Note
: this function must be called from the main NPL runtime thread,since it will execute NPL code internally.
Returns
the number of asynchronous download processed are returned.

Implements ParaEngine::INPLWebServiceClient.

§ ProcessResults()

int ParaEngine::CNPLNetClient::ProcessResults ( )
virtual

this function is called once on each frame to polling all results and calling the callbacks in scripting interface

Note
: this function must be called from the main NPL runtime thread,since it will execute NPL code internally.
Returns
the number of asynchronous messages processed are returned.

Implements ParaEngine::INPLWebServiceClient.

§ ProcessUrlRequests()

int ParaEngine::CNPLNetClient::ProcessUrlRequests ( )
virtual

this function is called once on each frame to polling all results and calling the callbacks in scripting interface

Note
: this function must be called from the main NPL runtime thread,since it will execute NPL code internally.
Returns
the number of asynchronous messages processed are returned.

Implements ParaEngine::INPLWebServiceClient.

§ RemovePendingRequest()

void ParaEngine::CNPLNetClient::RemovePendingRequest ( const char *  sURL)

remove a string url from a set.

This function is automatically called when a url request is completed.


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