Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

HandlerId

 

struct HandlerId

This simple concrete type is able to store both function to pointer or pack instance method id to be used as URL link base. Can be created from pointer to handler or as result of THISLINK or LINK macros.

 

 

Handler functions and macros

 

void RegisterHandler(void (*handler)(Http& http), const char *id, const char *path)

Registers handler function handler with the name id (id is usually the same as the name of function) that is supposed to handle path pattern.

 


 

SKYLARK(name, path)

Defines the handler function name (body follows the macro) supposed to handle path pattern.

 


 

SKYLARK_PROGRESS(name, path, progressCb)

Defines the handler function name (body follows the macro) supposed to handle path pattern, and setup a progressCb callback to handle progress feedback in lenghty operations.

progressCb must be a pointer to a function with following prototype:

 

        int progressCb(int reason, Http& http, int size);

 

progressCb is called many times during http transferm, with different reason values :

        reason == PROGRESS_HEADERS    when headers have been parsed and GET variables are ready

        reason == PROGRESS_CONTENT    during content transfer, with a frequency depending on TcpSocket WaitTime value (50 Hz by default)

        reason == PROGRESS_END    when transfer is complete

 

http is the Http object passed to Skylark handler

size has different meanings, depending on value :

        if reason == PROGRESS_HEADERS, size is the total contents size

        if reason == PROGRESS_CONTENT, size is the number of bytes transferred

        if reason == PROGRESS_END, size has no meaning.

 

The handler must return a non-zero value (true) if we want to continue transfer, a zero value (false) to abort current transfer.

You can see the SkylarkUpload example demo for usage.

 


 

String MakeLink(const HandlerId& id, const Vector<Value>& arg)

Based on handler and arg list of arguments, creates URL would get handled by this handler with specified arguments.

 


 

struct SkylarkPack

This is the base class of pack classed, which can be used to group and parametrize a set of handlers.

 


 

SKYLARK_USE(cls, id, path)

Creates an instance of pack cls as global variable id with path prefix.

 


 

SKYLARK_METHOD(method, path)

Registers a pack handler method to handler path pattern (this is combined with path prefix of SKYLARK_USE). Intended to be used in Use method of pack.

 


 

THISLINK(method)

Returns HandlerId of method - to be used within pack class.

 


 

LINK(instance, method)

Returns HandlerId of specific instance method.

 


 

SKYLARK_MEMBER(member, path)

Registers member variable subpack (in Use method).

 

Last edit by micio on 08/01/2013. Do you want to contribute?. T++