service.h File Reference


Detailed Description

Base class for all network services

Id
service.h,v 1.72 2004/01/29 17:14:44 lecroart Exp

Definition in file service.h.

#include "nel/misc/types_nl.h"
#include "nel/misc/config_file.h"
#include "nel/misc/entity_id.h"
#include "nel/misc/variable.h"
#include "nel/misc/command.h"
#include "nel/net/unified_network.h"
#include <string>
#include <vector>

Go to the source code of this file.

Namespaces

namespace  NLMISC
namespace  NLNET

Defines

#define NLNET_SERVICE_MAIN(__ServiceClassName, __ServiceShortName, __ServiceLongName, __ServicePort, __ServiceCallbackArray, __ConfigDir, __LogDir)


Define Documentation

#define NLNET_SERVICE_MAIN __ServiceClassName,
__ServiceShortName,
__ServiceLongName,
__ServicePort,
__ServiceCallbackArray,
__ConfigDir,
__LogDir   ) 
 

Value:

\
int main(int argc, const char **argv) \
{ \
        __ServiceClassName *scn = new __ServiceClassName; \
        scn->setArgs (argc, argv); \
        scn->setCallbackArray (__ServiceCallbackArray, sizeof(__ServiceCallbackArray)/sizeof(__ServiceCallbackArray[0])); \
        sint retval = scn->main (__ServiceShortName, __ServiceLongName, __ServicePort, __ConfigDir, __LogDir, __DATE__" "__TIME__); \
        delete scn; \
        return retval; \
}
The goal of this macro is to simplify the service creation, it creates the main body function.

If you don't want to give a callback array, just put EmptyCallbackArray in the last argument

Example:

// Create the Test Service class class CTestService : public IService { public: void init () { nlinfo("init()"); } bool update () { nlinfo ("update();"); return true; } void release () { nlinfo("release()"); } }; // Create the main() function that create a test service instance and execute it. // "TS" is the short service name and "test_service" is the long one. // The name of the config file is based on the long name! // EmptyCallbackArray means that you don't provide right now the callback // the last 2 path are where is the config file is (directory) and where to log info (directory) NLNET_SERVICE_MAIN(CTestService, "TS", "test_service", 0, EmptyCallbackArray, "", ""); *

If you want the port to not be auto-assigned by the naming service, set the port to a number different than 0.

Args used by service are always in lower case:

-A followed by the path where to execute the service (it uses chdir()) -B followed by the IP address where the naming service is -C followed by the path where we can find the config file -D followed by the client listening address of the frontend for the login system (FS only) -I to start the service iconified -L followed by the directory where we have to log -N followed by the alias name (used by the admin system) -P followed by the listen port (ListenAddress) -Q to make the service quit immediately after the first update -S followed by the shard Id (sint32) (WS only) -W followed by the path where to save all shard data (SaveFilesDirectory)

Definition at line 128 of file service.h.


Generated on Tue Mar 16 06:43:16 2004 for NeL by doxygen 1.3.6