NLNET::CCallbackServer Class Reference

Server class for layer 3. More...

#include <callback_server.h>

Inherits NLNET::CCallbackNetBase, and NLNET::CBufServer.

List of all members.

Public Member Functions

 CCallbackServer (TRecordingState rec=Off, const std::string &recfilename="", bool recordall=true, bool initPipeForDataAvailable=true)
 Constructor.
void send (const CMessage &buffer, TSockId hostid, bool log=true)
 Sends a message to the specified host.
bool flush (TSockId destid, uint *nbBytesRemaining=NULL)
 Force to send all data pending in the send queue. See comment in CCallbackNetBase.
void update2 (sint32 timeout=-1, sint32 mintime=0)
 Updates the network (call this method evenly).
void update (sint32 timeout=0)
 Updates the network (call this method evenly) (legacy).
void setConnectionCallback (TNetCallback cb, void *arg)
 Sets callback for incoming connections (or NULL to disable callback).
void setDisconnectionCallback (TNetCallback cb, void *arg)
 Sets callback for disconnections (or NULL to disable callback).
bool connected () const
 Returns true if the connection is still connected. on server, we always "connected".
void disconnect (TSockId hostid)
 Disconnect a connection Set hostid to InvalidSockId to disconnect all connections.
const CInetAddresshostAddress (TSockId hostid)
 Returns the address of the specified host.
virtual TSockId getSockId (TSockId hostid=InvalidSockId)
 Returns the sockid (cf. CCallbackClient).
uint64 getReceiveQueueSize ()
uint64 getSendQueueSize ()
void displayReceiveQueueStat (NLMISC::CLog *log=NLMISC::InfoLog)
void displaySendQueueStat (NLMISC::CLog *log=NLMISC::InfoLog, TSockId destid=InvalidSockId)
void displayThreadStat (NLMISC::CLog *log=NLMISC::InfoLog)

Private Member Functions

void send (const NLMISC::CMemStream &, TSockId)
 This function is public in the base class and put it private here because user cannot use it in layer 2.
bool dataAvailable ()
 Checks if there is some data to receive.
virtual bool getDataAvailableFlagV () const
 This function is implemented in the client and server class.
void receive (CMessage &buffer, TSockId *hostid)
 On this layer, you can't call directly receive, It s the update() function that receive and call your callaback.
void sendAllMyAssociations (TSockId to)

Private Attributes

TNetCallback _ConnectionCallback
 Connection callback.
void * _ConnectionCbArg
 Argument of the connection callback.

Friends

void cbsNewConnection (TSockId from, void *data)

Detailed Description

Server class for layer 3.

Author:
Vianney Lecroart
Nevrax France
Date:
2001

Definition at line 42 of file callback_server.h.


Constructor & Destructor Documentation

NLNET::CCallbackServer::CCallbackServer ( TRecordingState  rec = Off,
const std::string &  recfilename = "",
bool  recordall = true,
bool  initPipeForDataAvailable = true 
)

Member Function Documentation

bool NLNET::CCallbackServer::connected (  )  const [inline, virtual]

Returns true if the connection is still connected. on server, we always "connected".

Implements NLNET::CCallbackNetBase.

Definition at line 70 of file callback_server.h.

Referenced by getSockId(), receive(), send(), update(), and update2().

bool NLNET::CCallbackServer::dataAvailable (  )  [private]

Checks if there is some data to receive.

Returns false if the receive queue is empty. This is where the connection/disconnection callbacks can be called.

Reimplemented from NLNET::CBufServer.

Definition at line 265 of file callback_server.cpp.

References NLNET::CCallbackNetBase::Replay.

void NLNET::CCallbackServer::disconnect ( TSockId  hostid  )  [virtual]

Disconnect a connection Set hostid to InvalidSockId to disconnect all connections.

If hostid is not InvalidSockId and the socket is not connected, the method does nothing. Before disconnecting, any pending data is actually sent.

Implements NLNET::CCallbackNetBase.

Definition at line 231 of file callback_server.cpp.

References NLNET::CCallbackNetBase::Replay.

Referenced by NLNET::cbWSDisconnectClient(), and NLNET::CUnifiedNetwork::release().

void NLNET::CCallbackServer::displayReceiveQueueStat ( NLMISC::CLog log = NLMISC::InfoLog  )  [inline, virtual]

Implements NLNET::CCallbackNetBase.

Definition at line 88 of file callback_server.h.

void NLNET::CCallbackServer::displaySendQueueStat ( NLMISC::CLog log = NLMISC::InfoLog,
TSockId  destid = InvalidSockId 
) [inline]

Reimplemented from NLNET::CBufServer.

Definition at line 89 of file callback_server.h.

void NLNET::CCallbackServer::displayThreadStat ( NLMISC::CLog log = NLMISC::InfoLog  )  [inline]

Reimplemented from NLNET::CBufServer.

Definition at line 91 of file callback_server.h.

bool NLNET::CCallbackServer::flush ( TSockId  destid,
uint nbBytesRemaining = NULL 
) [inline]

Force to send all data pending in the send queue. See comment in CCallbackNetBase.

Reimplemented from NLNET::CBufServer.

Definition at line 53 of file callback_server.h.

References NLNET::InvalidSockId, and nlassert.

virtual bool NLNET::CCallbackServer::getDataAvailableFlagV (  )  const [inline, private, virtual]

This function is implemented in the client and server class.

Implements NLNET::CCallbackNetBase.

Definition at line 99 of file callback_server.h.

References NLNET::CBufNetBase::dataAvailableFlag().

uint64 NLNET::CCallbackServer::getReceiveQueueSize (  )  [inline, virtual]

Implements NLNET::CCallbackNetBase.

Definition at line 85 of file callback_server.h.

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

uint64 NLNET::CCallbackServer::getSendQueueSize (  )  [inline, virtual]

Implements NLNET::CCallbackNetBase.

Definition at line 86 of file callback_server.h.

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

TSockId NLNET::CCallbackServer::getSockId ( TSockId  hostid = InvalidSockId  )  [virtual]

Returns the sockid (cf. CCallbackClient).

Implements NLNET::CCallbackNetBase.

Definition at line 251 of file callback_server.cpp.

References connected(), NLNET::InvalidSockId, and nlassert.

const CInetAddress& NLNET::CCallbackServer::hostAddress ( TSockId  hostid  )  [inline]

Returns the address of the specified host.

Reimplemented from NLNET::CBufServer.

Definition at line 80 of file callback_server.h.

References NLNET::InvalidSockId, and nlassert.

void NLNET::CCallbackServer::receive ( CMessage buffer,
TSockId hostid 
) [private, virtual]

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

Implements NLNET::CCallbackNetBase.

Definition at line 191 of file callback_server.cpp.

References connected(), nlassert, NLNET::CMessage::readType(), NLNET::Receiving, NLNET::CCallbackNetBase::Record, and NLNET::CCallbackNetBase::Replay.

void NLNET::CCallbackServer::send ( const NLMISC::CMemStream ,
TSockId   
) [inline, private]

This function is public in the base class and put it private here because user cannot use it in layer 2.

Reimplemented from NLNET::CBufServer.

Definition at line 96 of file callback_server.h.

References nlstop.

void NLNET::CCallbackServer::send ( const CMessage buffer,
TSockId  hostid,
bool  log = true 
) [virtual]
void NLNET::CCallbackServer::sendAllMyAssociations ( TSockId  to  )  [private]
void NLNET::CCallbackServer::setConnectionCallback ( TNetCallback  cb,
void *  arg 
) [inline]

Sets callback for incoming connections (or NULL to disable callback).

Reimplemented from NLNET::CBufServer.

Definition at line 64 of file callback_server.h.

References _ConnectionCallback, and _ConnectionCbArg.

Referenced by CCallbackServer(), NLNET::CUnifiedNetwork::init(), and NLNET::CLoginServer::init().

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

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

Reimplemented from NLNET::CCallbackNetBase.

Definition at line 67 of file callback_server.h.

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

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

Updates the network (call this method evenly) (legacy).

Implements NLNET::CCallbackNetBase.

Definition at line 164 of file callback_server.cpp.

References NLNET::CCallbackNetBase::baseUpdate(), connected(), H_AUTO, nlassert, NLNET::CCallbackNetBase::Replay, and NLNET::CBufServer::update().

void NLNET::CCallbackServer::update2 ( sint32  timeout = -1,
sint32  mintime = 0 
) [virtual]

Updates the network (call this method evenly).

More info about timeout and mintime in the code of CCallbackNetBase::baseUpdate().

Implements NLNET::CCallbackNetBase.

Definition at line 137 of file callback_server.cpp.

References NLNET::CCallbackNetBase::baseUpdate2(), connected(), H_AUTO, nlassert, NLNET::CCallbackNetBase::Replay, and NLNET::CBufServer::update().


Friends And Related Function Documentation

void cbsNewConnection ( TSockId  from,
void *  data 
) [friend]

Definition at line 43 of file callback_server.cpp.

Referenced by CCallbackServer().


Member Data Documentation

Connection callback.

Reimplemented from NLNET::CBufServer.

Definition at line 105 of file callback_server.h.

Referenced by NLNET::cbsNewConnection(), and setConnectionCallback().

Argument of the connection callback.

Reimplemented from NLNET::CBufServer.

Definition at line 106 of file callback_server.h.

Referenced by NLNET::cbsNewConnection(), and setConnectionCallback().


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