#include <netthread.h>
Inheritance diagram for NetThread:
Public Member Functions | |
DECLSPEC | NetThread (const char *name, BasicObject *p, bool server=true, bool debug=true) |
DECLSPEC | NetThread (TiXmlElement *el, BasicObject *p) |
virtual const char * | getClassName () |
DECLSPEC void | connectSocket (NetSocket *s, const IPaddress &ip, BasicObject::Callback c, BasicObject *obj=NULL) |
void | setServerCheck (bool active) |
Static Public Member Functions | |
static DECLSPEC NetThread * | getThe () |
Static Public Attributes | |
static NetThread * | the |
Protected Member Functions | |
virtual DECLSPEC int | onRun () |
virtual DECLSPEC void | onCycle () |
virtual DECLSPEC void | onInit () |
virtual DECLSPEC void | onDestroy () |
Classes | |
struct | DATA |
This class handles network-events parallely.
Define "WEB_CLIENT", if this class need/must not poll the WebServer.
Use lock/unlock, when you want another thread/process to access the network.
If NetThread is not created with XML-data then it is automatically started when onInit() is called and stopped with onDestroy()!
This class must not be used in two variables at a time.
NetThread::NetThread | ( | const char * | name, | |
BasicObject * | p, | |||
bool | server = true , |
|||
bool | debug = true | |||
) |
Constructor, if WEB_CLIENT undefined.
server | if true, the webserver will be polled regularly if false not (equals WEB_CLIENT defined) | |
debug | if true, a log file is used for debugging, if false nothing will be logged. |
NetThread::NetThread | ( | TiXmlElement * | el, | |
BasicObject * | p | |||
) |
Constructor, for XML data.
el | the XML data, if the attribute "StartOnInit" is set true or does not exist, then the thread is started, when onInit() is called and stopped in onDestroy(). |
virtual const char* NetThread::getClassName | ( | ) | [inline, virtual] |
This function should be overriden in every sub-class of BasicObject!
Reimplemented from BasicThread.
void NetThread::connectSocket | ( | NetSocket * | s, | |
const IPaddress & | ip, | |||
BasicObject::Callback | c, | |||
BasicObject * | obj = NULL | |||
) |
Tries to connect the socket to the given IP address. This function may block the thread for some time.
s | the socket to connect | |
ip | the IP address to connect to | |
c | the function to call, when the task was done; NULL, if no function should be called | |
obj | the object, that recieves the function-call |
void NetThread::setServerCheck | ( | bool | active | ) | [inline] |
(De-)activates checking the webserver for requests.
active | must be true to activate the HTTP-server-functionality. |
NetThread * NetThread::getThe | ( | ) | [static] |
int NetThread::onRun | ( | ) | [protected, virtual] |
inherit onRun to have a function, called once (done in the new thread), when the thread is started
Reimplemented from BasicThread.
void NetThread::onCycle | ( | ) | [protected, virtual] |
inherit onCycle to get a function, called once per loop-cycle after starting the thread when using onCycle, the cycle-functions return a usable result note that this only happens, if onRun is not inherited or if it is called by a inherited function
Reimplemented from BasicThread.
void NetThread::onInit | ( | ) | [protected, virtual] |
Initializes the object's variables by reading data from the XML element. If there were no XML data used for creation, nothing is done. This function calls onInit() of its children recursively (after it has inited itself). It is highly recommended to call BasicObject::onInit(), usually at the end of the onInit() method, when overwriting it in a derived class.
Reimplemented from BasicLog.
void NetThread::onDestroy | ( | ) | [protected, virtual] |
May be called to reinitialise this object or stop an initialised module. Calls all children's onDestroy(). Most classes do not use this method. But sometimes it is useful to reset the functionality of an object.
Reimplemented from BasicObject.
NetThread * NetThread::the [static] |
only accessible in Linux, and equals the result of getThe()