From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a02352.html | 419 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 419 insertions(+) create mode 100644 docs/doxygen/nel/a02352.html (limited to 'docs/doxygen/nel/a02352.html') diff --git a/docs/doxygen/nel/a02352.html b/docs/doxygen/nel/a02352.html new file mode 100644 index 00000000..011314c4 --- /dev/null +++ b/docs/doxygen/nel/a02352.html @@ -0,0 +1,419 @@ + + +NeL: NLNET::CClientReceiveTask class Reference + + + +
+

NLNET::CClientReceiveTask Class Reference

#include <buf_client.h> +

+

Inheritance diagram for NLNET::CClientReceiveTask: +

+ +NLMISC::IRunnable + +

Detailed Description

+Code of receiving thread for clients +

+ +

+Definition at line 45 of file buf_client.h. + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

CNonBlockingBufSockbufSock ()
 Returns a pointer to the bufsock object.

 CClientReceiveTask (CBufClient *client, CNonBlockingBufSock *bufsock)
 Constructor (increments the reference to the object pointed to by the smart pointer sockid).

virtual void getName (std::string &result) const
virtual void run ()
 Run.

TSockId sockId ()
 Returns the socket identifier.


Data Fields

uint32 NbLoop

Private Attributes

CBufClient_Client
CNonBlockingBufSock_NBBufSock
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
NLNET::CClientReceiveTask::CClientReceiveTask CBufClient client,
CNonBlockingBufSock bufsock
[inline]
+
+ + + + + +
+   + + +

+Constructor (increments the reference to the object pointed to by the smart pointer sockid). +

+ +

+Definition at line 50 of file buf_client.h. +

+References _Client, _NBBufSock, and NbLoop. +

+

00050 : NbLoop(0), _Client(client), _NBBufSock(bufsock) {} // CHANGED: non-blocking client connection
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + +
CNonBlockingBufSock* NLNET::CClientReceiveTask::bufSock  )  [inline]
+
+ + + + + +
+   + + +

+Returns a pointer to the bufsock object. +

+ +

+Definition at line 56 of file buf_client.h. +

+References _NBBufSock. +

+

00056 { return _NBBufSock; } // CHANGED: non-blocking client connection (previously, returned _SockId->Sock)
+
+

+ + + + +
+ + + + + + + + + + +
virtual void NLMISC::IRunnable::getName std::string &  result  )  const [inline, virtual, inherited]
+
+ + + + + +
+   + + +

+ +

+Reimplemented in NL3D::CAsyncFileManager3D::CMeshLoad, NL3D::CAsyncFileManager3D::CIGLoad, NL3D::CAsyncFileManager3D::CIGLoadUser, NL3D::CAsyncFileManager3D::CTextureLoad, NL3D::CZoneLoadingTask, NLPACS::CGlobalRetriever::CLrLoader, NLMISC::CAsyncFileManager::CFileLoad, NLMISC::CAsyncFileManager::CMultipleFileLoad, and NLMISC::CAsyncFileManager::CSignal. +

+Definition at line 74 of file thread.h. +

+Referenced by NLMISC::CTaskManager::run(). +

+

00075         {
+00076                 result = "NoName";
+00077         }
+
+

+ + + + +
+ + + + + + + + + +
void NLNET::CClientReceiveTask::run  )  [virtual]
+
+ + + + + +
+   + + +

+Run. +

+ +

+Implements NLMISC::IRunnable. +

+Definition at line 437 of file buf_client.cpp. +

+References _Client, _NBBufSock, NLNET::CSock::dataAvailable(), NLNET::CTcpSock::disconnect(), NLNET::CNonBlockingBufSock::fillEventTypeOnly(), NLNET::NbClientReceiveTask, NbLoop, NLNET::NbNetworkTask, nldebug, nlnettrace, NLNET::CBufNetBase::pushMessageIntoReceiveQueue(), NLNET::CNonBlockingBufSock::receivedBuffer(), NLNET::CNonBlockingBufSock::receivePart(), NLNET::CSock::setTimeOutValue(), NLNET::CBufSock::Sock, and sockId(). +

+

00438 {
+00439         NbClientReceiveTask++;
+00440         NbNetworkTask++;
+00441         nlnettrace( "CClientReceiveTask::run" );
+00442 
+00443         _NBBufSock->Sock->setTimeOutValue( 60, 0 );
+00444 
+00445         bool connected = true;
+00446         while ( connected ) // does not call _Sock->connected() to avoid mutex (not needed for client)
+00447         {
+00448                 try
+00449                 {
+00450                         // ADDED: non-blocking client connection
+00451 
+00452                         // Wait until some data are received (sleepin' select inside)
+00453                         while ( ! _NBBufSock->Sock->dataAvailable() );
+00454 
+00455                         // Process the data received
+00456                         if ( _NBBufSock->receivePart( 1 ) ) // 1 for the event type
+00457                         {
+00458                                 //commented out for optimisation: nldebug( "LNETL1: Client %s received buffer (%u bytes)", _SockId->asString().c_str(), buffer.size()/*, stringFromVector(buffer).c_str()*/ );
+00459                                 // Add event type
+00460                                 _NBBufSock->fillEventTypeOnly();
+00461 
+00462                                 // Push message into receive queue
+00463                                 _Client->pushMessageIntoReceiveQueue( _NBBufSock->receivedBuffer() );
+00464                         }
+00465                         
+00466                         NbLoop++;
+00467 
+00468                         /* // OLD: blocking client connection
+00469                         // Receive message length (in blocking mode)
+00470                         TBlockSize blocklen;
+00471                         uint32 lenoflen = sizeof(blocklen);
+00472                         sock()->receive( (uint8*)&blocklen, lenoflen );
+00473                         uint32 len = ntohl( blocklen );
+00474         
+00475                         if ( len != 0 )
+00476                         {
+00477                                 // Test size limit
+00478                                 if ( len > _Client->maxExpectedBlockSize() )
+00479                                 {
+00480                                         nlwarning( "LNETL1: Socket %s received length exceeding max expected, in block header... Disconnecting", _SockId->asString().c_str() );
+00481                                         throw ESocket( "Received length exceeding max expected", false );
+00482                                 }
+00483 
+00484                                 // Receive message payload (in blocking mode)
+00485                                 CObjectVector<uint8> buffer;
+00486                                 buffer.resize(len+1);
+00487 
+00488                                 sock()->receive( buffer.getPtr(), len );
+00489                                 
+00490                                 //commented out for optimisation: nldebug( "LNETL1: Client %s received buffer (%u bytes)", _SockId->asString().c_str(), buffer.size() );
+00491                                 // Add event type
+00492                                 buffer[len] = CBufNetBase::User;
+00493 
+00494                                 // Push message into receive queue
+00495                                 _Client->pushMessageIntoReceiveQueue( buffer.getPtr(), buffer.size() );
+00496                         }
+00497                         else
+00498                         {
+00499                                 nlwarning( "LNETL1: Socket %s received null length in block header", _SockId->asString().c_str() );
+00500                         }
+00501                         */
+00502                 }
+00503                 catch ( ESocketConnectionClosed& )
+00504                 {
+00505                         nldebug( "LNETL1: Client connection %s closed", sockId()->asString().c_str() );
+00506                         // The socket went to _Connected=false when throwing the exception
+00507                         connected = false;
+00508                 }
+00509                 catch ( ESocket& )
+00510                 {
+00511                         nldebug( "LNETL1: Client connection %s broken", sockId()->asString().c_str() );
+00512                         sockId()->Sock->disconnect();
+00513                         connected = false;
+00514                 }
+00515         }
+00516 
+00517         nlnettrace( "Exiting CClientReceiveTask::run()" );
+00518         NbClientReceiveTask--;
+00519         NbNetworkTask--;
+00520 }
+
+

+ + + + +
+ + + + + + + + + +
TSockId NLNET::CClientReceiveTask::sockId  )  [inline]
+
+ + + + + +
+   + + +

+Returns the socket identifier. +

+ +

+Definition at line 59 of file buf_client.h. +

+References _NBBufSock, and NLNET::TSockId. +

+Referenced by run(). +

+

00059 { return (TSockId)_NBBufSock; }
+
+


Field Documentation

+

+ + + + +
+ + +
CBufClient* NLNET::CClientReceiveTask::_Client [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 65 of file buf_client.h. +

+Referenced by CClientReceiveTask(), and run().

+

+ + + + +
+ + +
CNonBlockingBufSock* NLNET::CClientReceiveTask::_NBBufSock [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 67 of file buf_client.h. +

+Referenced by bufSock(), CClientReceiveTask(), run(), and sockId().

+

+ + + + +
+ + +
uint32 NLNET::CClientReceiveTask::NbLoop +
+
+ + + + + +
+   + + +

+ +

+Definition at line 61 of file buf_client.h. +

+Referenced by CClientReceiveTask(), NLNET::CBufClient::displayThreadStat(), and run().

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 13:56:38 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1