# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLNET::IService Class Reference

Base class for all network services. More...

#include <service.h>

Inheritance diagram for NLNET::IService

Inheritance graph
[legend]
Collaboration diagram for NLNET::IService:

Collaboration graph
[legend]
List of all members.

Public Methods

 IService ()
 Constructor. More...

virtual ~IService ()
virtual void init ()
 Initializes the service (must be called before the first call to update()). More...

virtual bool update ()
 This function is called every "frame" (you must call init() before). It returns false if the service is stopped. More...

virtual void release ()
 Finalization. Release the service. For example, this founction free all allocation made in the init() function. More...

NLNET::TServiceId serviceId () const
 Returns the service identifier. More...

sint getStatus ()
 Returns the status. More...

void setStatus (sint status)
 Set the status of the service, this status is return to the application. EXIT_SUCCESS is the default status You can set it to EXIT_FAILURE or any value you want. It's useful when you use the service in a script and you want to know the return value of the application to do the appropriate things. More...

sint main (int argc, char **argv)
 User must just have to call this function in his main C function. More...

void setCallbackArray (TCallbackItem *callbackArray, uint16 callbackArraySize)

Static Public Methods

std::string serviceName ()
 Returns the current service name. More...

void setServiceName (const char *shortName, const char *longName)
void setPort (uint16 Port)
void setUpdateTimeout (uint32 timeout)
 Select timeout value in milliseconds for each update. More...

CCallbackServergetServer ()
 Returns a pointer to the CCallbackServer object. More...


Static Public Attributes

NLMISC::CConfigFile ConfigFile

Protected Methods

void getCustomParams ()
 Process command line arguments for port and timeout. More...

void setServiceId (NLNET::TServiceId sid)
 Sets the service identifier. More...


Protected Attributes

std::vector<std::string> _Args
 Array of arguments. More...

uint16 _Port
 Port for listening. More...


Static Protected Attributes

IService* Instance = NULL
 Singleton. More...

Static members that must be defined by the deriver class
std::string _ShortName = ""
 Current service name. Is set by the actual service when declaring NLNET_SERVICE_MAIN. More...

std::string _LongName = ""
uint16 _DefaultPort = 0
 Current service default port. Must be set by the deriver class. More...


Private Attributes

TServiceId _SId
sint _Status
bool _Initialized
TCallbackItem_CallbackArray
uint16 _CallbackArraySize

Static Private Attributes

uint32 _UpdateTimeout = 1
 Select timeout value in milliseconds. More...


Friends

void AESConnection (const std::string &serviceName, TSockId from, void *arg)

Detailed Description

Base class for all network services.

You must inherite from this class to create your own service. You must not create ctor and dtor but implement init() and release() methods. You have to create a global callback array called CallbackArray.

service_howto

Temporary command line arguments :

  • Arg 1 : port number for listening
  • Arg 2 : (optional) timeout for select in millisecond
Author(s):
Vianney Lecroart , Olivier Cado , Nevrax France
Date:
2000

Definition at line 101 of file service.h.


Constructor & Destructor Documentation

NLNET::IService::IService ( )
 

Constructor.

Definition at line 168 of file service.cpp.

NLNET::IService::~IService ( ) [inline, virtual]
 

Definition at line 108 of file service.h.


Member Function Documentation

void NLNET::IService::getCustomParams ( ) [protected]
 

Process command line arguments for port and timeout.

Definition at line 180 of file service.cpp.

CCallbackServer * NLNET::IService::getServer ( ) [static]
 

Returns a pointer to the CCallbackServer object.

Definition at line 265 of file service.cpp.

sint NLNET::IService::getStatus ( ) [inline]
 

Returns the status.

Definition at line 126 of file service.h.

void NLNET::IService::init ( void ) [inline, virtual]
 

Initializes the service (must be called before the first call to update()).

Reimplemented in CFrontEndService, CFrontEndService, and CChatService.

Definition at line 111 of file service.h.

sint NLNET::IService::main ( int argc,
char ** argv )
 

User must just have to call this function in his main C function.

Definition at line 272 of file service.cpp.

void NLNET::IService::release ( void ) [inline, virtual]
 

Finalization. Release the service. For example, this founction free all allocation made in the init() function.

Reimplemented in CFrontEndService, and CChatService.

Definition at line 117 of file service.h.

NLNET::TServiceId NLNET::IService::serviceId ( ) const [inline]
 

Returns the service identifier.

Definition at line 123 of file service.h.

std::string NLNET::IService::serviceName ( ) [inline, static]
 

Returns the current service name.

Definition at line 120 of file service.h.

void NLNET::IService::setCallbackArray ( TCallbackItem * callbackArray,
uint16 callbackArraySize ) [inline]
 

Definition at line 145 of file service.h.

void NLNET::IService::setPort ( uint16 Port ) [inline, static]
 

Definition at line 138 of file service.h.

void NLNET::IService::setServiceId ( NLNET::TServiceId sid ) [inline, protected]
 

Sets the service identifier.

Definition at line 177 of file service.h.

void NLNET::IService::setServiceName ( const char * shortName,
const char * longName ) [inline, static]
 

Definition at line 136 of file service.h.

void NLNET::IService::setStatus ( sint status ) [inline]
 

Set the status of the service, this status is return to the application. EXIT_SUCCESS is the default status You can set it to EXIT_FAILURE or any value you want. It's useful when you use the service in a script and you want to know the return value of the application to do the appropriate things.

Definition at line 131 of file service.h.

void NLNET::IService::setUpdateTimeout ( uint32 timeout ) [inline, static]
 

Select timeout value in milliseconds for each update.

If you set the value to 1000, the user update function will be call every second. By default the value is 1

Definition at line 143 of file service.h.

bool NLNET::IService::update ( ) [inline, virtual]
 

This function is called every "frame" (you must call init() before). It returns false if the service is stopped.

Reimplemented in CFrontEndService, and CChatService.

Definition at line 114 of file service.h.


Friends And Related Function Documentation

void AESConnection ( const std::string & serviceName,
TSockId from,
void * arg ) [friend]
 


Member Data Documentation

CConfigFile NLNET::IService::ConfigFile [static]
 

Definition at line 81 of file service.cpp.

IService * NLNET::IService::Instance = NULL [static, protected]
 

Singleton.

Definition at line 83 of file service.cpp.

std::vector< std::string > NLNET::IService::_Args [protected]
 

Array of arguments.

Definition at line 155 of file service.h.

TCallbackItem * NLNET::IService::_CallbackArray [private]
 

Definition at line 195 of file service.h.

uint16 NLNET::IService::_CallbackArraySize [private]
 

Definition at line 196 of file service.h.

uint16 NLNET::IService::_DefaultPort = 0 [static, protected]
 

Current service default port. Must be set by the deriver class.

Definition at line 76 of file service.cpp.

bool NLNET::IService::_Initialized [private]
 

Definition at line 193 of file service.h.

string NLNET::IService::_LongName = "" [static, protected]
 

Definition at line 75 of file service.cpp.

uint16 NLNET::IService::_Port [protected]
 

Port for listening.

Definition at line 158 of file service.h.

TServiceId NLNET::IService::_SId [private]
 

Definition at line 189 of file service.h.

string NLNET::IService::_ShortName = "" [static, protected]
 

Current service name. Is set by the actual service when declaring NLNET_SERVICE_MAIN.

Definition at line 74 of file service.cpp.

sint NLNET::IService::_Status [private]
 

Definition at line 191 of file service.h.

uint32 NLNET::IService::_UpdateTimeout = 1 [static, private]
 

Select timeout value in milliseconds.

Definition at line 78 of file service.cpp.


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