NLNET::CCallbackNetBase Class Reference

Layer 3. More...

#include <callback_net_base.h>

Inherited by NLNET::CCallbackClient, and NLNET::CCallbackServer.

List of all members.

Public Types

enum  TRecordingState { Off, Record, Replay }

Public Member Functions

virtual ~CCallbackNetBase ()
void setUserData (void *userData)
 Set the user data.
void * getUserData ()
 Get the user data.
virtual void send (const CMessage &buffer, TSockId hostid=InvalidSockId, bool log=true)=0
 Sends a message to special connection.
uint64 getBytesSent ()
uint64 getBytesReceived ()
virtual uint64 getReceiveQueueSize ()=0
virtual uint64 getSendQueueSize ()=0
virtual void displayReceiveQueueStat (NLMISC::CLog *log=NLMISC::InfoLog)=0
virtual void displaySendQueueStat (NLMISC::CLog *log=NLMISC::InfoLog, TSockId destid=InvalidSockId)=0
virtual void displayThreadStat (NLMISC::CLog *log=NLMISC::InfoLog)=0
virtual bool flush (TSockId hostid=InvalidSockId, uint *nbBytesRemaining=NULL)=0
 Force to send all data pending in the send queue.
void addCallbackArray (const TCallbackItem *callbackarray, sint arraysize)
 Appends callback array with the specified array.
void setDefaultCallback (TMsgCallback defaultCallback)
 Sets default callback for unknown message types.
void setPreDispatchCallback (TMsgCallback predispatchCallback)
 Set the pre dispatch callback. This callback is called before each message is dispatched.
void setDisconnectionCallback (TNetCallback cb, void *arg)
 Sets callback for disconnections (or NULL to disable callback).
virtual TSockId getSockId (TSockId hostid=InvalidSockId)=0
 returns the sockid of a connection. On a server, this function returns the parameter. On a client, it returns the connection.
void authorizeOnly (const char *callbackName, TSockId hostid=InvalidSockId)
 Sets the callback that you want the other side calls.
bool isAServer () const
 Returns true if this is a CCallbackServer.
virtual bool dataAvailable ()=0
 This function is implemented in the client and server class.
virtual bool getDataAvailableFlagV () const =0
 This function is implemented in the client and server class.
virtual void update2 (sint32 timeout=0, sint32 mintime=0)=0
 This function is implemented in the client and server class.
virtual void update (sint32 timeout=0)=0
 This function is implemented in the client and server class (legacy).
virtual bool connected () const =0
 This function is implemented in the client and server class.
virtual void disconnect (TSockId hostid=InvalidSockId)=0
 This function is implemented in the client and server class.
virtual const CInetAddresshostAddress (TSockId hostid)
 Returns the address of the specified host.

Protected Member Functions

 CCallbackNetBase (TRecordingState rec=Off, const std::string &recfilename="", bool recordall=true)
 Constructor.
void baseUpdate2 (sint32 timeout=-1, sint32 mintime=0)
 Used by client and server class More info about timeout and mintime in the code.
void baseUpdate (sint32 timeout=0)
 Used by client and server class (legacy).
void processOneMessage ()
 Read a message from the network and process it.
virtual void receive (CMessage &buffer, TSockId *hostid)=0
 On this layer, you can't call directly receive, It s the update() function that receive and call your callaback.

Protected Attributes

uint64 _BytesSent
uint64 _BytesReceived
TNetCallback _NewDisconnectionCallback
 Used by client and server class.
std::vector< TCallbackItem_CallbackArray
TMsgCallback _DefaultCallback
TMsgCallback _PreDispatchCallback
bool _IsAServer
bool _FirstUpdate

Private Attributes

void * _UserData
NLMISC::TTime _LastUpdateTime
NLMISC::TTime _LastMovedStringArray
TNetCallback _DisconnectionCallback
void * _DisconnectionCbArg

Friends

void cbnbMessageAskAssociations (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
void cbnbMessageRecvAssociations (CMessage &msgin, TSockId from, CCallbackNetBase &netbase)
void cbnbNewDisconnection (TSockId from, void *data)

Detailed Description

Layer 3.

Author:
Vianney Lecroart
Nevrax France
Date:
2001

Definition at line 73 of file callback_net_base.h.


Member Enumeration Documentation

Enumerator:
Off 
Record 
Replay 

Definition at line 155 of file callback_net_base.h.


Constructor & Destructor Documentation

virtual NLNET::CCallbackNetBase::~CCallbackNetBase (  )  [inline, virtual]

Definition at line 77 of file callback_net_base.h.

NLNET::CCallbackNetBase::CCallbackNetBase ( TRecordingState  rec = Off,
const std::string &  recfilename = "",
bool  recordall = true 
) [protected]

Constructor.

Definition at line 76 of file callback_net_base.cpp.

References NLMISC::createDebug(), Record, and Replay.


Member Function Documentation

void NLNET::CCallbackNetBase::addCallbackArray ( const TCallbackItem callbackarray,
sint  arraysize 
)

Appends callback array with the specified array.

You can add callback only *after* adding the server or the client.

Parameters:
arraysize is the number of callback items.

Definition at line 122 of file callback_net_base.cpp.

References _CallbackArray.

Referenced by NLNET::CLoginClient::authenticateBegin(), NLNET::CNamingClient::connect(), NLNET::CPacsClient::connect(), NLNET::CLoginClient::connectToShard(), NLNET::CUnifiedNetwork::init(), NLNET::CLoginServer::init(), and NLNET::_CUniTime::installServer().

void NLNET::CCallbackNetBase::authorizeOnly ( const char *  callbackName,
TSockId  hostid = InvalidSockId 
)

Sets the callback that you want the other side calls.

If it didn't call this callback, it will be disconnected If cb is NULL, we authorize *all* callback. On a client, the hostid must be InvalidSockId (or ommited). On a server, you must provide a hostid.

Definition at line 452 of file callback_net_base.cpp.

References NLNET::CBufSock::asString(), getSockId(), NLNET::InvalidSockId, LNETL3_DEBUG, and nlassert.

Referenced by NLNET::cbShardValidation(), and NLNET::ClientConnection().

void NLNET::CCallbackNetBase::baseUpdate ( sint32  timeout = 0  )  [protected]
void NLNET::CCallbackNetBase::baseUpdate2 ( sint32  timeout = -1,
sint32  mintime = 0 
) [protected]

Used by client and server class More info about timeout and mintime in the code.

Definition at line 330 of file callback_net_base.cpp.

References _FirstUpdate, _LastMovedStringArray, _LastUpdateTime, dataAvailable(), H_AUTO, nlassert, NLMISC::nlSleep(), and processOneMessage().

Referenced by NLNET::CCallbackServer::update2(), and NLNET::CCallbackClient::update2().

virtual bool NLNET::CCallbackNetBase::connected (  )  const [pure virtual]

This function is implemented in the client and server class.

Implemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

virtual bool NLNET::CCallbackNetBase::dataAvailable (  )  [pure virtual]

This function is implemented in the client and server class.

Implemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

Referenced by baseUpdate(), and baseUpdate2().

virtual void NLNET::CCallbackNetBase::disconnect ( TSockId  hostid = InvalidSockId  )  [pure virtual]
virtual void NLNET::CCallbackNetBase::displayReceiveQueueStat ( NLMISC::CLog log = NLMISC::InfoLog  )  [pure virtual]
virtual void NLNET::CCallbackNetBase::displaySendQueueStat ( NLMISC::CLog log = NLMISC::InfoLog,
TSockId  destid = InvalidSockId 
) [pure virtual]
virtual void NLNET::CCallbackNetBase::displayThreadStat ( NLMISC::CLog log = NLMISC::InfoLog  )  [pure virtual]
virtual bool NLNET::CCallbackNetBase::flush ( TSockId  hostid = InvalidSockId,
uint nbBytesRemaining = NULL 
) [pure virtual]

Force to send all data pending in the send queue.

On a client, the hostid isn't used and must be InvalidSockId On a server, you must provide a hostid. If you provide a non-null pointer for nbBytesRemaining, the value will be filled* will the number of bytes that still remain in the sending queue after the non-blocking flush attempt.

Implemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

uint64 NLNET::CCallbackNetBase::getBytesReceived (  )  [inline]

Definition at line 92 of file callback_net_base.h.

References _BytesReceived.

Referenced by NLNET::CUnifiedNetwork::getBytesReceived().

uint64 NLNET::CCallbackNetBase::getBytesSent (  )  [inline]

Definition at line 91 of file callback_net_base.h.

References _BytesSent.

Referenced by NLNET::CUnifiedNetwork::getBytesSent().

virtual bool NLNET::CCallbackNetBase::getDataAvailableFlagV (  )  const [pure virtual]

This function is implemented in the client and server class.

Implemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

virtual uint64 NLNET::CCallbackNetBase::getReceiveQueueSize (  )  [pure virtual]
virtual uint64 NLNET::CCallbackNetBase::getSendQueueSize (  )  [pure virtual]
virtual TSockId NLNET::CCallbackNetBase::getSockId ( TSockId  hostid = InvalidSockId  )  [pure virtual]

returns the sockid of a connection. On a server, this function returns the parameter. On a client, it returns the connection.

Implemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

Referenced by authorizeOnly(), NLNET::CUnifiedNetwork::CUnifiedConnection::TConnection::getAppId(), processOneMessage(), and NLNET::CUnifiedNetwork::CUnifiedConnection::TConnection::setAppId().

void * NLNET::CCallbackNetBase::getUserData (  ) 

Get the user data.

Definition at line 114 of file callback_net_base.cpp.

References _UserData.

const CInetAddress & NLNET::CCallbackNetBase::hostAddress ( TSockId  hostid  )  [virtual]

Returns the address of the specified host.

Reimplemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

Definition at line 444 of file callback_net_base.cpp.

References nlstop.

Referenced by NLNET::cbServerAskUniversalTime(), NLNET::cbShardValidation(), and NLNET::uncbServiceIdentification().

bool NLNET::CCallbackNetBase::isAServer (  )  const [inline]

Returns true if this is a CCallbackServer.

Definition at line 136 of file callback_net_base.h.

References _IsAServer.

void NLNET::CCallbackNetBase::processOneMessage (  )  [protected]
virtual void NLNET::CCallbackNetBase::receive ( CMessage buffer,
TSockId hostid 
) [protected, pure virtual]

On this layer, you can't call directly receive, It s the update() function that receive and call your callaback.

Implemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

Referenced by processOneMessage().

virtual void NLNET::CCallbackNetBase::send ( const CMessage buffer,
TSockId  hostid = InvalidSockId,
bool  log = true 
) [pure virtual]

Sends a message to special connection.

On a client, the hostid isn't used. On a server, you must provide a hostid. If you hostid = InvalidSockId, the message will be sent to all connected client.

Implemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

Referenced by NLNET::cbServerAskUniversalTime(), and NLNET::cbShardValidation().

void NLNET::CCallbackNetBase::setDefaultCallback ( TMsgCallback  defaultCallback  )  [inline]

Sets default callback for unknown message types.

Definition at line 117 of file callback_net_base.h.

References _DefaultCallback.

Referenced by NLNET::CUnifiedNetwork::addService(), and NLNET::CUnifiedNetwork::init().

void NLNET::CCallbackNetBase::setDisconnectionCallback ( TNetCallback  cb,
void *  arg 
) [inline]

Sets callback for disconnections (or NULL to disable callback).

Reimplemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

Definition at line 123 of file callback_net_base.h.

References _DisconnectionCallback, and _DisconnectionCbArg.

void NLNET::CCallbackNetBase::setPreDispatchCallback ( TMsgCallback  predispatchCallback  )  [inline]

Set the pre dispatch callback. This callback is called before each message is dispatched.

Definition at line 120 of file callback_net_base.h.

References _PreDispatchCallback.

void NLNET::CCallbackNetBase::setUserData ( void *  userData  ) 

Set the user data.

Definition at line 108 of file callback_net_base.cpp.

References _UserData.

virtual void NLNET::CCallbackNetBase::update ( sint32  timeout = 0  )  [pure virtual]

This function is implemented in the client and server class (legacy).

Implemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.

virtual void NLNET::CCallbackNetBase::update2 ( sint32  timeout = 0,
sint32  mintime = 0 
) [pure virtual]

This function is implemented in the client and server class.

Implemented in NLNET::CCallbackClient, and NLNET::CCallbackServer.


Friends And Related Function Documentation

void cbnbMessageAskAssociations ( CMessage msgin,
TSockId  from,
CCallbackNetBase netbase 
) [friend]
void cbnbMessageRecvAssociations ( CMessage msgin,
TSockId  from,
CCallbackNetBase netbase 
) [friend]
void cbnbNewDisconnection ( TSockId  from,
void *  data 
) [friend]

Definition at line 55 of file callback_net_base.cpp.


Member Data Documentation

Definition at line 159 of file callback_net_base.h.

Referenced by getBytesReceived(), and processOneMessage().

Definition at line 182 of file callback_net_base.h.

Referenced by addCallbackArray(), and processOneMessage().

Definition at line 213 of file callback_net_base.h.

Referenced by NLNET::cbnbNewDisconnection(), and setDisconnectionCallback().

Definition at line 214 of file callback_net_base.h.

Referenced by NLNET::cbnbNewDisconnection(), and setDisconnectionCallback().

Definition at line 191 of file callback_net_base.h.

Referenced by baseUpdate(), and baseUpdate2().

Definition at line 211 of file callback_net_base.h.

Referenced by baseUpdate(), and baseUpdate2().

Definition at line 210 of file callback_net_base.h.

Referenced by baseUpdate(), and baseUpdate2().

Used by client and server class.

Definition at line 162 of file callback_net_base.h.

Referenced by NLNET::CCallbackClient::CCallbackClient(), and NLNET::CCallbackServer::CCallbackServer().

Definition at line 188 of file callback_net_base.h.

Referenced by processOneMessage(), and setPreDispatchCallback().

Definition at line 208 of file callback_net_base.h.

Referenced by getUserData(), and setUserData().


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