# 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::CNetManager Class Reference

Layer 4. More...

#include <net_manager.h>

List of all members.

Static Public Methods

void init (const CInetAddress *addr, CCallbackNetBase::TRecordingState rec)
 Creates the connection to the Naming Service. More...

void release ()
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. More...

void addServer (const std::string &serviceName, uint16 servicePort, NLNET::TServiceId &sid, bool external=false)
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). More...

void addClient (const std::string &serviceName)
 Creates a connection to a service using the naming service and the serviceName. More...

void addGroup (const std::string &groupName, const std::string &serviceName)
 Creates connections to a group of service. More...

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. More...

void update (NLMISC::TTime timeout=0)
 Call it evenly. More...

void send (const std::string &serviceName, const CMessage &buffer, TSockId hostid=InvalidSockId)
 Sends a message to a specific serviceName. More...

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. More...

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. More...

NLMISC::CStringIdArraygetSIDA (const std::string &serviceName)
 Use this function to get the String ID Array needed when you want to create a message. More...

CCallbackNetBasegetNetBase (const std::string &serviceName)
 Returns the connection if you want to do specific calls. More...

void setUpdateTimeout (uint32 timeout)
void createConnection (CBaseStruct &Base, const CInetAddress &Addr, const std::string &name)
uint64 getBytesSent ()
uint64 getBytesReceived ()
uint64 getReceiveQueueSize ()
uint64 getSendQueueSize ()

Private Types

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

Private Methods

 CNetManager ()

Static Private Methods

ItBaseMap find (const std::string &serviceName)

Static Private Attributes

TBaseMap _BaseMap
CCallbackNetBase::TRecordingState _RecordingState
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 99 of file net_manager.h.


Member Typedef Documentation

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

Definition at line 171 of file net_manager.h.

Referenced by addCallbackArray, addClient, addGroup, addServer, getBytesReceived, getBytesSent, getNetBase, getReceiveQueueSize, getSendQueueSize, getSIDA, release, send, setConnectionCallback, setDisconnectionCallback, and update.

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

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.

Definition at line 346 of file net_manager.cpp.

References find, ItBaseMap, nldebug, and NLMISC::CStringIdArray::TStringId.

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 280 of file net_manager.cpp.

References _RecordingState, find, ItBaseMap, 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 256 of file net_manager.cpp.

References addr, createConnection, find, ItBaseMap, 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 307 of file net_manager.cpp.

References createConnection, find, ItBaseMap, nlassert, and nldebug.

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

Definition at line 207 of file net_manager.cpp.

References _RecordingState, addr, find, ItBaseMap, nlassert, nldebug, nlinfo, NLNET::nmNewConnection, NLNET::nmNewDisconnection, and NLNET::TServiceId.

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 201 of file net_manager.cpp.

References NLNET::TServiceId.

void NLNET::CNetManager::createConnection CBaseStruct   Base,
const CInetAddress   Addr,
const std::string &    name
[static]
 

Referenced by addClient, and addGroup.

CNetManager::ItBaseMap NLNET::CNetManager::find const std::string &    serviceName [static, private]
 

Definition at line 489 of file net_manager.cpp.

References _BaseMap.

Referenced by addCallbackArray, addClient, addGroup, addServer, getNetBase, getSIDA, send, setConnectionCallback, and setDisconnectionCallback.

uint64 NLNET::CNetManager::getBytesReceived   [static]
 

Definition at line 510 of file net_manager.cpp.

References _BaseMap, and ItBaseMap.

uint64 NLNET::CNetManager::getBytesSent   [static]
 

Definition at line 497 of file net_manager.cpp.

References _BaseMap, and ItBaseMap.

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

Returns the connection if you want to do specific calls.

Definition at line 466 of file net_manager.cpp.

References find, and ItBaseMap.

uint64 NLNET::CNetManager::getReceiveQueueSize   [static]
 

Definition at line 536 of file net_manager.cpp.

References _BaseMap, and ItBaseMap.

uint64 NLNET::CNetManager::getSendQueueSize   [static]
 

Definition at line 523 of file net_manager.cpp.

References _BaseMap, and ItBaseMap.

NLMISC::CStringIdArray & NLNET::CNetManager::getSIDA const std::string &    serviceName [static]
 

Use this function to get the String ID Array needed when you want to create a message.

Definition at line 335 of file net_manager.cpp.

References find, ItBaseMap, nlassert, and nldebug.

void NLNET::CNetManager::init const CInetAddress   addr,
CCallbackNetBase::TRecordingState    rec
[static]
 

Creates the connection to the Naming Service.

If the connection failed, ESocketConnectionFailed exception is generated.

Definition at line 169 of file net_manager.cpp.

References _RecordingState, addr, RegistrationBroadcast, and NLNET::UnregistrationBroadcast.

void NLNET::CNetManager::release   [static]
 

Definition at line 185 of file net_manager.cpp.

References _BaseMap, and ItBaseMap.

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 455 of file net_manager.cpp.

References find, ItBaseMap, nldebug, and NLNET::TSockId.

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 472 of file net_manager.cpp.

References find, ItBaseMap, nldebug, and NLNET::TNetManagerCallback.

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 480 of file net_manager.cpp.

References find, ItBaseMap, nldebug, and NLNET::TNetManagerCallback.

void NLNET::CNetManager::setUpdateTimeout uint32    timeout [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).

Definition at line 357 of file net_manager.cpp.

References _BaseMap, _NextUpdateTime, ItBaseMap, nlassert, nlinfo, NLMISC::nlSleep, and NLMISC::TTime.


Friends And Related Function Documentation

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

Referenced by init.


Member Data Documentation

CNetManager::TBaseMap NLNET::CNetManager::_BaseMap [static, private]
 

Definition at line 56 of file net_manager.cpp.

Referenced by find, getBytesReceived, getBytesSent, getReceiveQueueSize, getSendQueueSize, release, and update.

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

Definition at line 60 of file net_manager.cpp.

Referenced by update.

CCallbackNetBase::TRecordingState NLNET::CNetManager::_RecordingState [static, private]
 

Definition at line 58 of file net_manager.cpp.

Referenced by addClient, addServer, and init.


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