NLNET::CNetManager Class Reference

Layer 4. More...

#include <net_manager.h>

List of all members.

Static Public Member Functions

static void init (const CInetAddress *addr, CCallbackNetBase::TRecordingState rec)
 Creates the connection to the Naming Service.
static void release ()
static void addServer (const std::string &serviceName, uint16 servicePort=0, bool external=false)
 Sets up a server on a specific port with a specific service name (create a listen socket, register to naming service and so on) If servicePort is 0, it will be dynamically determinated by the Naming Service.
static void addServer (const std::string &serviceName, uint16 servicePort, NLNET::TServiceId &sid, bool external=false)
static void addClient (const std::string &serviceName, const std::string &addr, bool autoRetry=true)
 Creates a connection to a specific IP and associate it this a "fake" serviceName (to enable you to send data for example).
static void addClient (const std::string &serviceName)
 Creates a connection to a service using the naming service and the serviceName.
static void addGroup (const std::string &groupName, const std::string &serviceName)
 Creates connections to a group of service.
static void addCallbackArray (const std::string &serviceName, const TCallbackItem *callbackarray, NLMISC::CStringIdArray::TStringId arraysize)
 Adds a callback array to a specific service connection. You can add callback only *after* adding the server, the client or the group.
static void update (NLMISC::TTime timeout=0)
 Call it evenly.
static void send (const std::string &serviceName, const CMessage &buffer, TSockId hostid=InvalidSockId)
 Sends a message to a specific serviceName.
static void setConnectionCallback (const std::string &serviceName, TNetManagerCallback cb, void *arg)
 Sets callback for incoming connections (or NULL to disable callback) On a client, the callback will be call when the connection to the server is established (the first connection or after the server shutdown and started) On a server, the callback is called each time a new client is connected to him.
static void setDisconnectionCallback (const std::string &serviceName, TNetManagerCallback cb, void *arg)
 Sets callback for disconnections (or NULL to disable callback) On a client, the callback will be call each time the connection to the server is lost On a server, the callback is called each time a client is disconnected.
static CCallbackNetBasegetNetBase (const std::string &serviceName)
 Returns the connection if you want to do specific calls.
static void setUpdateTimeout (uint32 timeout)
static void createConnection (CBaseStruct &Base, const CInetAddress &Addr, const std::string &name)
static uint64 getBytesSent ()
static uint64 getBytesReceived ()
static uint64 getReceiveQueueSize ()
static uint64 getSendQueueSize ()

Private Types

typedef std::map< std::string,
CBaseStruct
TBaseMap
typedef TBaseMap::iterator ItBaseMap

Private Member Functions

 CNetManager ()

Static Private Member Functions

static ItBaseMap find (const std::string &serviceName)

Static Private Attributes

static TBaseMap _BaseMap
static
CCallbackNetBase::TRecordingState 
_RecordingState
static NLMISC::TTime _NextUpdateTime = 0

Friends

void RegistrationBroadcast (const std::string &name, TServiceId sid, const std::vector< CInetAddress > &addr)

Detailed Description

Layer 4.

In case of addGroup(), messages are *not* associate with id, so the message type is always sent with string.

Author:
Vianney Lecroart
Nevrax France
Date:
2001

Definition at line 102 of file net_manager.h.


Member Typedef Documentation

typedef TBaseMap::iterator NLNET::CNetManager::ItBaseMap [private]

Definition at line 171 of file net_manager.h.

typedef std::map<std::string, CBaseStruct> NLNET::CNetManager::TBaseMap [private]

Definition at line 170 of file net_manager.h.


Constructor & Destructor Documentation

NLNET::CNetManager::CNetManager (  )  [inline, private]

Definition at line 188 of file net_manager.h.


Member Function Documentation

static void NLNET::CNetManager::addCallbackArray ( const std::string &  serviceName,
const TCallbackItem callbackarray,
NLMISC::CStringIdArray::TStringId  arraysize 
) [static]

Adds a callback array to a specific service connection. You can add callback only *after* adding the server, the client or the group.

void NLNET::CNetManager::addClient ( const std::string &  serviceName  )  [static]

Creates a connection to a service using the naming service and the serviceName.

Definition at line 264 of file net_manager.cpp.

References _RecordingState, NLNET::CBaseStruct::Client, NLNET::CNamingClient::connected(), find(), NLNET::CNamingClient::lookupAndConnect(), nlassert, nldebug, and NLNET::nmNewDisconnection().

void NLNET::CNetManager::addClient ( const std::string &  serviceName,
const std::string &  addr,
bool  autoRetry = true 
) [static]

Creates a connection to a specific IP and associate it this a "fake" serviceName (to enable you to send data for example).

Definition at line 240 of file net_manager.cpp.

References NLNET::CBaseStruct::ClientWithAddr, createConnection(), find(), nlassert, and nldebug.

void NLNET::CNetManager::addGroup ( const std::string &  groupName,
const std::string &  serviceName 
) [static]

Creates connections to a group of service.

Definition at line 291 of file net_manager.cpp.

References NLNET::CNamingClient::connected(), createConnection(), find(), NLNET::CBaseStruct::Group, NLNET::CNamingClient::lookupAll(), nlassert, and nldebug.

void NLNET::CNetManager::addServer ( const std::string &  serviceName,
uint16  servicePort,
NLNET::TServiceId sid,
bool  external = false 
) [static]
void NLNET::CNetManager::addServer ( const std::string &  serviceName,
uint16  servicePort = 0,
bool  external = false 
) [static]

Sets up a server on a specific port with a specific service name (create a listen socket, register to naming service and so on) If servicePort is 0, it will be dynamically determinated by the Naming Service.

If sid id 0, the service id will be dynamically determinated by the Naming Service.

Definition at line 185 of file net_manager.cpp.

void NLNET::CNetManager::createConnection ( CBaseStruct Base,
const CInetAddress Addr,
const std::string &  name 
) [static]
CNetManager::ItBaseMap NLNET::CNetManager::find ( const std::string &  serviceName  )  [static, private]
uint64 NLNET::CNetManager::getBytesReceived (  )  [static]

Definition at line 481 of file net_manager.cpp.

References _BaseMap.

uint64 NLNET::CNetManager::getBytesSent (  )  [static]

Definition at line 468 of file net_manager.cpp.

References _BaseMap.

CCallbackNetBase * NLNET::CNetManager::getNetBase ( const std::string &  serviceName  )  [static]

Returns the connection if you want to do specific calls.

Definition at line 437 of file net_manager.cpp.

References find().

uint64 NLNET::CNetManager::getReceiveQueueSize (  )  [static]

Definition at line 507 of file net_manager.cpp.

References _BaseMap.

uint64 NLNET::CNetManager::getSendQueueSize (  )  [static]

Definition at line 494 of file net_manager.cpp.

References _BaseMap.

void NLNET::CNetManager::init ( const CInetAddress addr,
CCallbackNetBase::TRecordingState  rec 
) [static]
void NLNET::CNetManager::release ( void   )  [static]
void NLNET::CNetManager::send ( const std::string &  serviceName,
const CMessage buffer,
TSockId  hostid = InvalidSockId 
) [static]

Sends a message to a specific serviceName.

Definition at line 426 of file net_manager.cpp.

References NLNET::CBufSock::asString(), find(), nldebug, and NLNET::CMessage::toString().

void NLNET::CNetManager::setConnectionCallback ( const std::string &  serviceName,
TNetManagerCallback  cb,
void *  arg 
) [static]

Sets callback for incoming connections (or NULL to disable callback) On a client, the callback will be call when the connection to the server is established (the first connection or after the server shutdown and started) On a server, the callback is called each time a new client is connected to him.

Definition at line 443 of file net_manager.cpp.

References find(), and nldebug.

void NLNET::CNetManager::setDisconnectionCallback ( const std::string &  serviceName,
TNetManagerCallback  cb,
void *  arg 
) [static]

Sets callback for disconnections (or NULL to disable callback) On a client, the callback will be call each time the connection to the server is lost On a server, the callback is called each time a client is disconnected.

Definition at line 451 of file net_manager.cpp.

References find(), and nldebug.

static void NLNET::CNetManager::setUpdateTimeout ( uint32  timeout  )  [static]
static void NLNET::CNetManager::update ( NLMISC::TTime  timeout = 0  )  [static]

Call it evenly.

the parameter select the timeout value in milliseconds for each update. You are absolutely certain that this function will not be returns before this amount of time you set. If you set the update timeout value higher than 0, all messages in queues will be process until the time is greater than the timeout user update(). If you set the update timeout value to 0, all messages in queues will be process one time before calling the user update(). In this case, we don't nlSleep(1).


Friends And Related Function Documentation

void RegistrationBroadcast ( const std::string &  name,
TServiceId  sid,
const std::vector< CInetAddress > &  addr 
) [friend]

Definition at line 115 of file net_manager.cpp.

Referenced by init().


Member Data Documentation

TTime NLNET::CNetManager::_NextUpdateTime = 0 [static, private]

Definition at line 179 of file net_manager.h.

Definition at line 176 of file net_manager.h.

Referenced by addClient(), addServer(), createConnection(), and init().


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

Generated on Thu Jan 7 08:30:20 2010 for NeL by  doxygen 1.6.1