From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/new_service_howto.html | 127 ++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 docs/doxygen/nel/new_service_howto.html (limited to 'docs/doxygen/nel/new_service_howto.html') diff --git a/docs/doxygen/nel/new_service_howto.html b/docs/doxygen/nel/new_service_howto.html new file mode 100644 index 00000000..d74d1f56 --- /dev/null +++ b/docs/doxygen/nel/new_service_howto.html @@ -0,0 +1,127 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# 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  
+

How to create a new service ?

+
+Author(s):
+ Olivier Cado +

+

+Date:
+ Updated May 4, 2001 +

+

Introduction

+ +

+A service is set of functionnalities provided by a server. The class NLNET::IService is the base class of all services. +

+NLNET::IService performs automatically the basic functionnalities of any service, such as registration to the Naming Service, server start-up and shutdown. +

+NLNET::IService is located in NeL, but user-defined services are located in /code/nelns. +

+

How to create a user-defined service ?

+ +

+

    +
  1. Create a class inherited from NLNET::IService (optional).
  2. Create an array of callbacks, called CallbackArray. Example :
    void cbProcessConnection( CMessage& message, TSockId from, CCallbackNetBase& nb )
    +{
    +        // Process here
    +}
    +
    +void cbProcessReceivedMsg( CMessage& message, TSockId from, CCallbackNetBase& nb )
    +{
    +        // Process incoming message here
    +}
    +
    +TCallbackItem CallbackArray[] =
    +{
    +        { "LOG", cbProcessReceivedMsg },
    +        { "C", cbProcessConnection }
    +};
  3. Reimplement the methods init(), update() and release() if you need to (optional). After each call to update(), CNetManager::update() is automatically called, so that the server can handle incoming messages (by calling the callbacks) and flush buffers of outgoing data.
  4. Add in your source file the NLNET_SERVICE_MAIN line, with the following arguments :
+
    +
  • The name of your class (or NLNET::IService if you do not inherit from it (*))
  • The short name of your service
  • Its long name
  • The chosen port number (set it to 0 for "auto-assigned by the naming service")
  • The callback array
+Example:
NLNET_SERVICE_MAIN( CMyService, "MS", "my_service", 0, CallbackArray );
+

+(*) Note: if your service does nothing else calling your callbacks, i.e. init(), update() and release() are empty, you don't need to create a new class : you can use IService directly and write IService instead of CMyService. +

+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;
+

+

Examples

+ +

+See the nelns services source code for examples on how to create a class inherited from IService. +

+ + + +
                                                                                                                                                                    +

+ + -- cgit v1.2.1