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

Server class for layer 3. More...

#include <callback_server.h>

Inheritance diagram for NLNET::CCallbackServer:

NLNET::CCallbackNetBase NLNET::CBufServer NLNET::CBufNetBase List of all members.

Public Methods

 CCallbackServer (TRecordingState rec=Off, const std::string &recfilename="", bool recordall=true)
 Constructor. More...

void send (const CMessage &buffer, TSockId hostid, bool log=true)
 Sends a message to the specified host. More...

bool flush (TSockId destid)
 Force to send all data pending in the send queue. More...

void update (sint32 timeout=0)
 Updates the network (call this method evenly). More...

void setConnectionCallback (TNetCallback cb, void *arg)
 Sets callback for incoming connections (or NULL to disable callback). More...

void setDisconnectionCallback (TNetCallback cb, void *arg)
 Sets callback for disconnections (or NULL to disable callback). More...

bool connected () const
 Returns true if the connection is still connected. on server, we always "connected". More...

void disconnect (TSockId hostid)
 Disconnect a connection Set hostid to InvalidSockId to disconnect all connections. More...

const CInetAddresshostAddress (TSockId hostid)
 Returns the address of the specified host. More...

virtual TSockId getSockId (TSockId hostid=InvalidSockId)
 Returns the sockid (cf. CCallbackClient). More...

uint64 getReceiveQueueSize ()
uint64 getSendQueueSize ()

Private Methods

void send (const NLMISC::CMemStream &buffer, TSockId hostid)
 This function is public in the base class and put it private here because user cannot use it in layer 2. More...

bool dataAvailable ()
 Checks if there is some data to receive. More...

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

void sendAllMyAssociations (TSockId to)
 Used by client and server class. More...


Private Attributes

TNetCallback _ConnectionCallback
 Connection callback. More...

void * _ConnectionCbArg
 Argument of the connection callback. More...


Friends

void cbsNewConnection (TSockId from, void *data)

Detailed Description

Server class for layer 3.

Author:
Vianney Lecroart , Nevrax France
Date:
2001

Definition at line 44 of file callback_server.h.


Constructor & Destructor Documentation

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

Constructor.


Member Function Documentation

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

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

Reimplemented from NLNET::CCallbackNetBase.

Definition at line 67 of file callback_server.h.

References NLNET::CCallbackNetBase::checkThreadId.

Referenced by getSockId, receive, send, sendAllMyAssociations, and update.

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

References NLNET::CCallbackNetBase::checkThreadId, and 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.

Reimplemented from NLNET::CCallbackNetBase.

Definition at line 243 of file callback_server.cpp.

References NLNET::CCallbackNetBase::checkThreadId, NLNET::CCallbackNetBase::Replay, and NLNET::TSockId.

bool NLNET::CCallbackServer::flush TSockId    destid [inline]
 

Force to send all data pending in the send queue.

Reimplemented from NLNET::CBufServer.

Definition at line 55 of file callback_server.h.

References NLNET::CCallbackNetBase::checkThreadId, nlassert, and NLNET::TSockId.

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

Implements NLNET::CCallbackNetBase.

Definition at line 82 of file callback_server.h.

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

Implements NLNET::CCallbackNetBase.

Definition at line 83 of file callback_server.h.

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

Returns the sockid (cf. CCallbackClient).

Implements NLNET::CCallbackNetBase.

Definition at line 265 of file callback_server.cpp.

References NLNET::CCallbackNetBase::checkThreadId, connected, nlassert, and NLNET::TSockId.

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

Returns the address of the specified host.

Reimplemented from NLNET::CBufServer.

Definition at line 77 of file callback_server.h.

References NLNET::CCallbackNetBase::checkThreadId, nlassert, and NLNET::TSockId.

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 202 of file callback_server.cpp.

References NLNET::CCallbackNetBase::checkThreadId, connected, nlassert, NLNET::Receiving, NLNET::CCallbackNetBase::Record, NLNET::CCallbackNetBase::Replay, and NLNET::TSockId.

void NLNET::CCallbackServer::send const NLMISC::CMemStream   buffer,
TSockId    hostid
[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 88 of file callback_server.h.

References nlstop, and NLNET::TSockId.

void NLNET::CCallbackServer::send const CMessage   buffer,
TSockId    hostid,
bool    log = true
[virtual]
 

Sends a message to the specified host.

Implements NLNET::CCallbackNetBase.

Definition at line 124 of file callback_server.cpp.

References NLNET::CCallbackNetBase::_BytesSent, NLNET::CCallbackNetBase::checkThreadId, connected, NLNET::CBufServer::nbConnections, nlassert, NLNET::CCallbackNetBase::Record, NLNET::CCallbackNetBase::Replay, NLNET::Sending, and NLNET::TSockId.

Referenced by sendAllMyAssociations.

void NLNET::CCallbackServer::sendAllMyAssociations TSockId    to [private]
 

Used by client and server class.

Reimplemented from NLNET::CCallbackNetBase.

Definition at line 91 of file callback_server.cpp.

References NLNET::CCallbackNetBase::_OutputSIDA, NLNET::CCallbackNetBase::checkThreadId, connected, NLNET::CCallbackNetBase::getSIDA, NLMISC::CStringIdArray::getString, nlassert, nldebug, send, NLMISC::CStringIdArray::size, and NLNET::TSockId.

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 61 of file callback_server.h.

References _ConnectionCallback, _ConnectionCbArg, NLNET::CCallbackNetBase::checkThreadId, and NLNET::TNetCallback.

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 64 of file callback_server.h.

References NLNET::CCallbackNetBase::checkThreadId, and NLNET::TNetCallback.

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

Updates the network (call this method evenly).

Reimplemented from NLNET::CCallbackNetBase.

Definition at line 175 of file callback_server.cpp.

References NLNET::CCallbackNetBase::baseUpdate, NLNET::CCallbackNetBase::checkThreadId, connected, nlassert, and NLNET::CCallbackNetBase::Replay.


Friends And Related Function Documentation

void cbsNewConnection TSockId    from,
void *    data
[friend]
 

Definition at line 45 of file callback_server.cpp.


Member Data Documentation

TNetCallback NLNET::CCallbackServer::_ConnectionCallback [private]
 

Connection callback.

Reimplemented from NLNET::CBufServer.

Definition at line 95 of file callback_server.h.

Referenced by setConnectionCallback.

void* NLNET::CCallbackServer::_ConnectionCbArg [private]
 

Argument of the connection callback.

Reimplemented from NLNET::CBufServer.

Definition at line 96 of file callback_server.h.

Referenced by setConnectionCallback.


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