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

Client class for layer 3. More...

#include <callback_client.h>

Inheritance diagram for NLNET::CCallbackClient:

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

Public Methods

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

void send (const CMessage &buffer, TSockId hostid=InvalidSockId, bool log=true)
 Sends a message to the remote host (the second parameter isn't used). More...

bool flush (TSockId hostid=InvalidSockId)
 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 connect (const CInetAddress &addr)
 Connects to the specified host. More...

virtual bool connected () const
 Returns true if the connection is still connected (changed when a disconnection event has reached the front of the receive queue, just before calling the disconnection callback if there is one). More...

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

void disconnect (TSockId hostid=InvalidSockId)
 Disconnect a connection Unlike in CCallbackClient, you can call disconnect() on a socket that is already disconnected (it will do nothing). More...

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

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

uint64 getReceiveQueueSize ()
uint64 getSendQueueSize ()

Private Methods

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

bool dataAvailable ()
 Returns true if there are messages to read. More...

void receive (CMessage &buffer, TSockId *hostid=NULL)
 On this layer, you can't call directly receive, It s the update() function that receive and call your callaback. More...


Private Attributes

uint32 SendNextValue
uint32 ReceiveNextValue

Detailed Description

Client class for layer 3.

Author:
Vianney Lecroart, Olivier Cado , Nevrax France
Date:
2001

Definition at line 46 of file callback_client.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 59 of file callback_client.cpp.

References NLNET::CCallbackNetBase::_DefaultCallback, NLNET::CCallbackNetBase::_InputSIDA, NLNET::CCallbackNetBase::_IsAServer, NLNET::CCallbackNetBase::_NewDisconnectionCallback, NLNET::CCallbackNetBase::addCallbackArray, NLNET::ClientMessageAssociationArray, and NLMISC::CStringIdArray::ignoreAllUnknownId.


Member Function Documentation

void NLNET::CCallbackClient::connect const CInetAddress   addr
 

Connects to the specified host.

Reimplemented from NLNET::CBufClient.

Definition at line 283 of file callback_client.cpp.

References NLNET::CBufClient::_BufSock, NLNET::CBufClient::_NoDelay, NLNET::CBufClient::_PrevBytesDownloaded, NLNET::CBufClient::_PrevBytesUploaded, addr, NLNET::CCallbackNetBase::checkThreadId, NLNET::Connecting, NLNET::ConnFailing, nlassert, nlwarning, ReceiveNextValue, NLNET::CCallbackNetBase::Record, NLNET::CCallbackNetBase::Replay, SendNextValue, and NLNET::TNetworkEvent.

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

Returns true if the connection is still connected (changed when a disconnection event has reached the front of the receive queue, just before calling the disconnection callback if there is one).

Reimplemented from NLNET::CBufClient.

Definition at line 69 of file callback_client.h.

References NLNET::CCallbackNetBase::checkThreadId.

Referenced by receive, and send.

bool NLNET::CCallbackClient::dataAvailable   [private]
 

Returns true if there are messages to read.

Reimplemented from NLNET::CBufClient.

Definition at line 189 of file callback_client.cpp.

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

void NLNET::CCallbackClient::disconnect TSockId    hostid = InvalidSockId [virtual]
 

Disconnect a connection Unlike in CCallbackClient, you can call disconnect() on a socket that is already disconnected (it will do nothing).

Reimplemented from NLNET::CCallbackNetBase.

Definition at line 351 of file callback_client.cpp.

References NLNET::CBufClient::_BufSock, NLNET::CCallbackNetBase::checkThreadId, NLNET::Disconnecting, nlassert, nlwarning, ReceiveNextValue, NLNET::CCallbackNetBase::Replay, SendNextValue, and NLNET::TSockId.

bool NLNET::CCallbackClient::flush TSockId    hostid = InvalidSockId [virtual]
 

Force to send all data pending in the send queue.

Implements NLNET::CCallbackNetBase.

Definition at line 134 of file callback_client.cpp.

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

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

Implements NLNET::CCallbackNetBase.

Definition at line 85 of file callback_client.h.

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

Implements NLNET::CCallbackNetBase.

Definition at line 86 of file callback_client.h.

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

Returns the sockid.

Implements NLNET::CCallbackNetBase.

Definition at line 269 of file callback_client.cpp.

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

virtual const CInetAddress& NLNET::CCallbackClient::hostAddress TSockId    hostid [inline, virtual]
 

Returns the address of the specified host.

Reimplemented from NLNET::CCallbackNetBase.

Definition at line 71 of file callback_client.h.

References NLNET::CBufClient::remoteAddress, and NLNET::TSockId.

void NLNET::CCallbackClient::receive CMessage   buffer,
TSockId   hostid = NULL
[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 217 of file callback_client.cpp.

References NLNET::CCallbackNetBase::checkThreadId, connected, NLNET::CBufClient::id, nlassert, NLMISC_BSWAP32, nlstopex, ReceiveNextValue, NLNET::Receiving, NLNET::CCallbackNetBase::Record, NLNET::CCallbackNetBase::Replay, and NLNET::TSockId.

void NLNET::CCallbackClient::send const NLMISC::CMemStream   buffer [inline, private]
 

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

Reimplemented from NLNET::CBufClient.

Definition at line 91 of file callback_client.h.

References nlstop.

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

Sends a message to the remote host (the second parameter isn't used).

Implements NLNET::CCallbackNetBase.

Definition at line 79 of file callback_client.cpp.

References NLNET::CCallbackNetBase::_BytesSent, NLNET::CCallbackNetBase::checkThreadId, connected, nlassert, NLMISC_BSWAP32, NLNET::CCallbackNetBase::Record, NLNET::CCallbackNetBase::Replay, NLNET::Sending, SendNextValue, and NLNET::TSockId.

void NLNET::CCallbackClient::setDisconnectionCallback TNetCallback    cb,
void *    arg
[inline]
 

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

Reimplemented from NLNET::CCallbackNetBase.

Definition at line 80 of file callback_client.h.

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

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

Updates the network (call this method evenly).

Reimplemented from NLNET::CCallbackNetBase.

Definition at line 162 of file callback_client.cpp.

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


Member Data Documentation

uint32 NLNET::CCallbackClient::ReceiveNextValue [private]
 

Definition at line 106 of file callback_client.h.

Referenced by connect, disconnect, and receive.

uint32 NLNET::CCallbackClient::SendNextValue [private]
 

Definition at line 106 of file callback_client.h.

Referenced by connect, disconnect, and send.


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