Client class for layer 3. More...
#include <callback_client.h>
Inherits NLNET::CCallbackNetBase, and NLNET::CBufClient.
Public Member Functions | |
| CCallbackClient (TRecordingState rec=Off, const std::string &recfilename="", bool recordall=true, bool initPipeForDataAvailable=true) | |
| Constructor. | |
| ~CCallbackClient () | |
| void | send (const CMessage &buffer, TSockId hostid=InvalidSockId, bool log=true) |
| Sends a message to the remote host (the second parameter isn't used). | |
| bool | flush (TSockId hostid=InvalidSockId, uint *nbBytesRemaining=NULL) |
| Force to send all data pending in the send queue. hostid must be InvalidSockId here. 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 | connect (const CInetAddress &addr) |
| Connects to the specified host. | |
| 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). | |
| virtual const CInetAddress & | hostAddress (TSockId) |
| Returns the address of the specified host. | |
| 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). | |
| void | setDisconnectionCallback (TNetCallback cb, void *arg) |
| Sets callback for disconnections (or NULL to disable callback). | |
| virtual TSockId | getSockId (TSockId hostid=InvalidSockId) |
| Returns the sockid. | |
| uint64 | getReceiveQueueSize () |
| uint64 | getSendQueueSize () |
| void | displayReceiveQueueStat (NLMISC::CLog *log=NLMISC::InfoLog) |
| void | displaySendQueueStat (NLMISC::CLog *log=NLMISC::InfoLog, TSockId=InvalidSockId) |
| void | displayThreadStat (NLMISC::CLog *log=NLMISC::InfoLog) |
Private Member Functions | |
| void | send (const NLMISC::CMemStream &) |
| These function is public in the base class and put it private here because user cannot use it in layer 2. | |
| bool | dataAvailable () |
| Returns true if there are messages to read. | |
| virtual bool | getDataAvailableFlagV () const |
| This function is implemented in the client and server class. | |
| 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. | |
Private Attributes | |
| bool | LockDeletion |
Client class for layer 3.
Definition at line 44 of file callback_client.h.
| NLNET::CCallbackClient::CCallbackClient | ( | TRecordingState | rec = Off, |
|
| const std::string & | recfilename = "", |
|||
| bool | recordall = true, |
|||
| bool | initPipeForDataAvailable = true | |||
| ) |
Constructor.
Definition at line 43 of file callback_client.cpp.
References NLNET::CCallbackNetBase::_DefaultCallback, NLNET::CCallbackNetBase::_IsAServer, NLNET::CCallbackNetBase::_NewDisconnectionCallback, LockDeletion, and setDisconnectionCallback().
| NLNET::CCallbackClient::~CCallbackClient | ( | ) |
Definition at line 53 of file callback_client.cpp.
References LockDeletion, and nlassert.
| void NLNET::CCallbackClient::connect | ( | const CInetAddress & | addr | ) |
Connects to the specified host.
Reimplemented from NLNET::CBufClient.
Definition at line 269 of file callback_client.cpp.
References NLNET::CBufClient::_BufSock, NLNET::CBufClient::_NoDelay, NLNET::CBufClient::_PrevBytesDownloaded, NLNET::CBufClient::_PrevBytesUploaded, NLNET::CBufSock::connect(), NLNET::CSock::connected(), NLNET::Connecting, NLNET::ConnFailing, NL_I64, nlassert, nlwarning, NLNET::CCallbackNetBase::Record, NLNET::CCallbackNetBase::Replay, NLMISC::CMemStream::serial(), and NLNET::CBufSock::Sock.
Referenced by NLNET::CUnifiedNetwork::addService(), NLNET::CLoginClient::authenticateBegin(), NLNET::CUnifiedNetwork::autoReconnect(), NLNET::CNamingClient::connect(), NLNET::CLoginClient::connectToShard(), NLNET::CNetManager::createConnection(), NLNET::CNamingClient::lookupAndConnect(), NLNET::CAliveCheck::run(), NLNET::CNetDisplayer::setLogServer(), and NLNET::CGatewayL3ClientTransport::update().
| 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 73 of file callback_client.h.
Referenced by NLNET::CLoginClient::authenticateBegin(), NLNET::CLoginClient::authenticateUpdate(), NLNET::CLoginClient::confirmConnection(), NLNET::CNamingClient::connect(), NLNET::CGatewayL3ClientTransport::connect(), NLNET::CPacsClient::connect(), NLNET::CNetDisplayer::connected(), NLNET::CNamingClient::connected(), NLNET::CLoginClient::connectToShard(), NLNET::CNamingClient::disconnect(), NLNET::CNetDisplayer::doDisplay(), NLNET::CGatewayL3ClientTransport::dump(), NLNET::CNamingClient::lookup(), NLNET::CNamingClient::lookupAll(), NLNET::CNamingClient::lookupAlternate(), NLNET::CNamingClient::lookupAndConnect(), NLNET::CNamingClient::queryServicePort(), NLNET::CNamingClient::registerService(), NLNET::CNamingClient::registerServiceWithSId(), NLNET::CNamingClient::resendRegisteration(), NLNET::CLoginClient::selectShardBegin(), NLNET::CLoginClient::selectShardUpdate(), send(), NLNET::CL3ClientRoute::sendMessage(), NLNET::CNetDisplayer::setLogServer(), NLNET::CNamingClient::unregisterAllServices(), NLNET::CNamingClient::unregisterService(), NLNET::CNamingClient::update(), and NLNET::CGatewayL3ClientTransport::update().
| bool NLNET::CCallbackClient::dataAvailable | ( | ) | [private] |
Returns true if there are messages to read.
Reimplemented from NLNET::CBufClient.
Definition at line 188 of file callback_client.cpp.
References 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).
Implements NLNET::CCallbackNetBase.
Definition at line 333 of file callback_client.cpp.
References NLNET::CBufClient::_BufSock, NLNET::CBufSock::connectedState(), NLNET::Disconnecting, NLNET::InvalidSockId, NL_I64, nlassert, nlwarning, and NLNET::CCallbackNetBase::Replay.
Referenced by NLNET::CLoginClient::authenticateBegin(), NLNET::CLoginClient::authenticateUpdate(), NLNET::CLoginClient::confirmConnection(), NLNET::CNamingClient::disconnect(), NLNET::CPacsClient::disconnect(), NLNET::CAliveCheck::run(), NLNET::CLoginClient::selectShardBegin(), NLNET::CLoginClient::selectShardUpdate(), and NLNET::CNetDisplayer::~CNetDisplayer().
| void NLNET::CCallbackClient::displayReceiveQueueStat | ( | NLMISC::CLog * | log = NLMISC::InfoLog |
) | [inline, virtual] |
Implements NLNET::CCallbackNetBase.
Definition at line 92 of file callback_client.h.
Referenced by NLNET::CGatewayL3ClientTransport::dump().
| void NLNET::CCallbackClient::displaySendQueueStat | ( | NLMISC::CLog * | log = NLMISC::InfoLog, |
|
| TSockId | = InvalidSockId | |||
| ) | [inline, virtual] |
Implements NLNET::CCallbackNetBase.
Definition at line 93 of file callback_client.h.
Referenced by NLNET::CGatewayL3ClientTransport::dump().
| void NLNET::CCallbackClient::displayThreadStat | ( | NLMISC::CLog * | log = NLMISC::InfoLog |
) | [inline] |
Reimplemented from NLNET::CBufClient.
Definition at line 95 of file callback_client.h.
| bool NLNET::CCallbackClient::flush | ( | TSockId | hostid = InvalidSockId, |
|
| uint * | nbBytesRemaining = NULL | |||
| ) | [virtual] |
Force to send all data pending in the send queue. hostid must be InvalidSockId here. See comment in CCallbackNetBase.
Implements NLNET::CCallbackNetBase.
Definition at line 101 of file callback_client.cpp.
References NLNET::InvalidSockId, nlassert, and NLNET::CCallbackNetBase::Replay.
Referenced by NLNET::CGatewayL3ClientTransport::update().
| virtual bool NLNET::CCallbackClient::getDataAvailableFlagV | ( | ) | const [inline, private, virtual] |
This function is implemented in the client and server class.
Implements NLNET::CCallbackNetBase.
Definition at line 104 of file callback_client.h.
References NLNET::CBufNetBase::dataAvailableFlag().
| uint64 NLNET::CCallbackClient::getReceiveQueueSize | ( | ) | [inline, virtual] |
Implements NLNET::CCallbackNetBase.
Definition at line 89 of file callback_client.h.
| uint64 NLNET::CCallbackClient::getSendQueueSize | ( | ) | [inline, virtual] |
Implements NLNET::CCallbackNetBase.
Definition at line 90 of file callback_client.h.
| TSockId NLNET::CCallbackClient::getSockId | ( | TSockId | hostid = InvalidSockId |
) | [virtual] |
Returns the sockid.
Implements NLNET::CCallbackNetBase.
Definition at line 256 of file callback_client.cpp.
References NLNET::CBufClient::id(), NLNET::InvalidSockId, and nlassert.
Referenced by NLNET::CUnifiedNetwork::addService(), NLNET::CNetManager::createConnection(), and NLNET::CGatewayL3ClientTransport::deletePendingRoute().
| virtual const CInetAddress& NLNET::CCallbackClient::hostAddress | ( | TSockId | hostid | ) | [inline, virtual] |
Returns the address of the specified host.
Reimplemented from NLNET::CCallbackNetBase.
Definition at line 75 of file callback_client.h.
References NLNET::CBufClient::remoteAddress().
| 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 214 of file callback_client.cpp.
References NLNET::CMessage::buffer(), NLNET::InvalidSockId, NLMISC_BSWAP32, NLNET::CMessage::readType(), NLNET::Receiving, NLNET::CCallbackNetBase::Record, and NLNET::CCallbackNetBase::Replay.
| void NLNET::CCallbackClient::send | ( | const NLMISC::CMemStream & | ) | [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 100 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 63 of file callback_client.cpp.
References NLNET::CCallbackNetBase::_BytesSent, connected(), NLNET::InvalidSockId, NLNET::CMessage::length(), nlassert, NLNET::CCallbackNetBase::Record, NLNET::CCallbackNetBase::Replay, NLNET::Sending, and NLNET::CMessage::typeIsSet().
Referenced by NLNET::CUnifiedNetwork::addService(), NLNET::CLoginClient::authenticateBegin(), NLNET::cbUnregisterBroadcast(), NLNET::CLoginClient::confirmConnection(), NLNET::CLoginClient::connectToShard(), NLNET::CNetDisplayer::doDisplay(), NLNET::CNamingClient::queryServicePort(), NLNET::CNamingClient::registerService(), NLNET::CNamingClient::registerServiceWithSId(), NLNET::CNamingClient::resendRegisteration(), NLNET::CLoginClient::selectShardBegin(), NLNET::CL3ClientRoute::sendMessage(), NLNET::CPacsClient::sendMessage(), and NLNET::CNamingClient::unregisterService().
| 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 84 of file callback_client.h.
Referenced by NLNET::CUnifiedNetwork::addService(), and CCallbackClient().
| void NLNET::CCallbackClient::update | ( | sint32 | timeout = 0 |
) | [virtual] |
Updates the network (call this method evenly) (legacy).
Implements NLNET::CCallbackNetBase.
Definition at line 158 of file callback_client.cpp.
References NLNET::CCallbackNetBase::baseUpdate(), H_AUTO, LockDeletion, NLNET::CCallbackNetBase::Replay, and NLNET::CBufClient::update().
Referenced by NLNET::CLoginClient::authenticateUpdate(), NLNET::CLoginClient::confirmConnection(), NLNET::CLoginClient::connectToShard(), NLNET::CNamingClient::queryServicePort(), NLNET::CNamingClient::registerService(), NLNET::CNamingClient::registerServiceWithSId(), NLNET::CLoginClient::selectShardUpdate(), NLNET::CNamingClient::update(), and NLNET::CPacsClient::update().
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 128 of file callback_client.cpp.
References NLNET::CCallbackNetBase::baseUpdate2(), H_AUTO, LockDeletion, NLNET::CCallbackNetBase::Replay, and NLNET::CBufClient::update().
Referenced by NLNET::CGatewayL3ClientTransport::update().
bool NLNET::CCallbackClient::LockDeletion [private] |
Definition at line 113 of file callback_client.h.
Referenced by CCallbackClient(), update(), update2(), and ~CCallbackClient().
1.6.1