The callback array
Example:
(*) Note: if your service does nothing else than calling your callbacks, i.e. init(), update() and release() are empty, you don't need to create a new class : you can use NLMISC::IService5
directly and write NLMISC::IService5
instead of CMyService
.
(**) Note: the long name is used to find the config file. If the long name is "ping_service" the service will try to open the config file named "ping_service.cfg"
To run your service, create a file "<service_long_name>.cfg" in the working directory, containing the location of your naming service.
Example: my_service.cfg:
NSHost = "itsalive.nevrax.org";
NSPort = 50000;
Update rules
Use the setUpdateTimeout()
to set the quantum of time use for the network update. You are absolutely certain that your update()
function will not be called before this amount of time.
If you set the update time-out value higher than 0, all messages in queue will be processed until the time becomes greater than the time-out, before calling the user update()
.
If you set the update time-out value to 0, all messages in queue will be processed once before calling the user update()
.
If you set the update time-out value to -1, only one message will be process once before calling the user update()
.
The default time-out is 100ms, therefore the update()
function of your service will be called every 100ms or so.
Examples
See the NeLNS services source code for examples on how to create a class inherited from NLMISC::IService5
.
Note that some NeLNS services use the old IService class and it's normal because these services are special.
All your services should use service 5 and if not, you should know exactly how to deal with that.
See also the net_layer5 samples in the nel/samples/net_layer5
directory.
Take a look on the nel/include/nel/net/service_5.h
and nel/include/nel/net/unified_network.h
header for more information about methods.