#include <buf_sock.h>
Inheritance diagram for NLNET::CServerBufSock:
Definition at line 337 of file buf_sock.h.
Public Member Functions | |
uint64 | appId () const |
Returns the application identifier. | |
std::string | asString () const |
Returns a string with the characteristics of the object. | |
void | setAppId (uint64 id) |
Sets the application identifier. | |
Data Fields | |
std::string | AuthorizedCallback |
uint32 | ReceiveNextValue |
uint32 | SendNextValue |
Protected Member Functions | |
bool | advertiseConnection (CBufServer *bnb) |
bool | advertiseDisconnection (CBufNetBase *bnb, TSockId sockid) |
bool | advertiseSystemEvent (CBufNetBase *bnb, TSockId sockid, bool &flag, bool condition, CBufNetBase::TEventType event) |
void | connect (const CInetAddress &addr, bool nodelay, bool connectedstate) |
Connects to the specified addr; set connectedstate to true if no connection advertising is needed. | |
bool | connectedState () const |
Returns the "logically connected" state (changed when processing a connection/disconnection callback). | |
CServerBufSock (CTcpSock *sock) | |
void | disconnect (bool connectedstate) |
Disconnects; set connectedstate to false if no disconnection advertising is needed. | |
void | fillEventTypeOnly () |
Fill the event type byte at pos length()(for a client connection). | |
void | fillSockIdAndEventType (TSockId sockId) |
Fill the sockid and the event type byte at the end of the buffer. | |
uint32 | length () const |
CServerReceiveTask * | ownerTask () |
Returns the task that "owns" the CServerBufSock object. | |
bool | pushBuffer (const NLMISC::CMemStream &buffer) |
const std::vector< uint8 > | receivedBuffer () const |
bool | receivePart (uint32 nbExtraBytes) |
void | setConnectedState (bool connectedstate) |
Sets the "logically connected" state (changed when processing a connection/disconnection callback). | |
void | setMaxExpectedBlockSize (sint32 limit) |
Set the size limit for received blocks. | |
void | setNonBlocking () |
void | setOwnerTask (CServerReceiveTask *owner) |
Sets the task that "owns" the CServerBufSock object. | |
virtual std::string | typeStr () const |
Returns "SRV " (server). | |
Sending data | |
bool | flush () |
void | setSizeFlushTrigger (sint32 size) |
void | setTimeFlushTrigger (sint32 ms) |
bool | update () |
Update the network sending (call this method evenly). Returns false if an error occured. | |
Sending data | |
bool | flush () |
void | setSizeFlushTrigger (sint32 size) |
void | setTimeFlushTrigger (sint32 ms) |
bool | update () |
Update the network sending (call this method evenly). Returns false if an error occured. | |
Sending data | |
bool | flush () |
void | setSizeFlushTrigger (sint32 size) |
void | setTimeFlushTrigger (sint32 ms) |
bool | update () |
Update the network sending (call this method evenly). Returns false if an error occured. | |
Protected Attributes | |
bool | _KnowConnected |
uint32 | _MaxExpectedBlockSize |
std::vector< uint8 > | _ReceiveBuffer |
NLMISC::CBufFIFO | SendFifo |
CTcpSock * | Sock |
Private Attributes | |
bool | _Advertised |
True after a connection callback has been sent to the user, for this connection. | |
CServerReceiveTask * | _OwnerTask |
Friends | |
class | CBufClient |
class | CBufServer |
class | CCallbackClient |
class | CCallbackNetBase |
class | CCallbackServer |
class | CClientReceiveTask |
class | CListenTask |
class | CServerReceiveTask |
|
Constructor with an existing socket (created by an accept()). Don't forget to call setOwnerTask(). Definition at line 370 of file buf_sock.cpp. References nlassert, and nlnettrace.
00370 : 00371 CNonBlockingBufSock( sock ), 00372 _Advertised( false ), 00373 _OwnerTask( NULL ) 00374 { 00375 nlassert (this != InvalidSockId); // invalid bufsock 00376 nlnettrace( "CServerBufSock::CServerBufSock" ); 00377 } |
|
Pushes a connection message into bnb's receive queue, if it has not already been done (returns true in this case). Definition at line 359 of file buf_sock.h. References NLNET::CBufSock::advertiseSystemEvent(). Referenced by NLNET::CListenTask::run().
00360 { 00361 return advertiseSystemEvent( (CBufNetBase*)bnb, this, _KnowConnected, false, CBufNetBase::Connection ); 00362 } |
|
Pushes a disconnection message into bnb's receive queue, if it has not already been done (returns true in this case). You can either specify a sockid (for server) or InvalidSockId (for client) Definition at line 120 of file buf_sock.h. References NLNET::CBufSock::_KnowConnected, NLNET::CBufSock::advertiseSystemEvent(), nlassert, and NLNET::TSockId. Referenced by NLNET::CBufClient::send(), and NLNET::CBufClient::update().
00121 { 00122 #ifdef NL_DEBUG 00123 if ( sockid != InvalidSockId ) 00124 { 00125 nlassert( sockid == this ); 00126 } 00127 #endif 00128 return advertiseSystemEvent( bnb, sockid, _KnowConnected, true, CBufNetBase::Disconnection ); 00129 } |
|
Pushes a system message into bnb's receive queue, if the flags meets the condition, then resets the flag and returns true. You can either specify a sockid (for server) or InvalidSockId (for client). Definition at line 135 of file buf_sock.h. References NLNET::CBufSock::asString(), buffer, condition, nlassert, nldebug, NLNET::CBufNetBase::pushMessageIntoReceiveQueue(), and NLNET::TSockId. Referenced by advertiseConnection(), and NLNET::CBufSock::advertiseDisconnection().
00137 { 00138 #ifdef NL_DEBUG 00139 if ( sockid != InvalidSockId ) 00140 { 00141 nlassert( sockid == this ); 00142 } 00143 #endif 00144 // Test flag 00145 if ( flag==condition ) 00146 { 00147 nldebug( "LNETL1: Pushing event to %s", asString().c_str() ); 00148 std::vector<uint8> buffer; 00149 if ( sockid == InvalidSockId ) 00150 { 00151 // Client: event type only 00152 buffer.resize( 1 ); 00153 buffer[0] = event; 00154 } 00155 else 00156 { 00157 // Server: sockid + event type 00158 buffer.resize( sizeof(TSockId) + 1 ); 00159 memcpy( &*buffer.begin(), &sockid, sizeof(TSockId) ); 00160 buffer[sizeof(TSockId)] = event; 00161 } 00162 // Push 00163 bnb->pushMessageIntoReceiveQueue( buffer ); 00164 00165 // Reset flag 00166 flag = !condition; 00167 return true; 00168 } 00169 else 00170 { 00171 return false; 00172 } 00173 } |
|
Returns the application identifier.
Definition at line 63 of file buf_sock.h. References NLNET::CBufSock::_AppId, and uint64. Referenced by NLNET::CUnifiedNetwork::CUnifiedConnection::TConnection::getAppId().
00063 { return _AppId; }
|
|
Returns a string with the characteristics of the object.
Definition at line 329 of file buf_sock.cpp. References NLNET::CSock::descriptor(), NLNET::CBufSock::Sock, NLMISC::toString(), NLMISC::toStringPtr(), and NLNET::CBufSock::typeStr(). Referenced by NLNET::CBufSock::advertiseSystemEvent(), NLNET::CCallbackNetBase::authorizeOnly(), NLNET::CBufServer::dataAvailable(), NLNET::CBufSock::flush(), NLNET::CCallbackNetBase::processOneMessage(), NLNET::CNonBlockingBufSock::receivePart(), NLNET::CServerReceiveTask::run(), NLNET::CListenTask::run(), NLNET::CNetManager::send(), and NLNET::CCallbackServer::sendAllMyAssociations().
00330 { 00331 // stringstream ss; 00332 string str; 00333 if (this == InvalidSockId) // tricky 00334 str = "<null>"; 00335 else 00336 { 00337 // if it crashs here, it means that the CBufSock was deleted and you try to access to the virtual table that is empty 00338 // because the object is destroyed. 00339 str += typeStr(); 00340 str += NLMISC::toStringPtr(this) + " (socket "; 00341 00342 if (Sock == NULL) 00343 str += "<null>"; 00344 else 00345 str += NLMISC::toString(Sock->descriptor()); 00346 00347 str += ")"; 00348 } 00349 return str; 00350 } |
|
Connects to the specified addr; set connectedstate to true if no connection advertising is needed.
Definition at line 295 of file buf_sock.cpp. References NLNET::CBufSock::_ConnectedState, NLNET::CBufSock::_KnowConnected, addr, NLNET::CTcpSock::connect(), NLNET::CSock::connected(), nlassert, NLNET::CBufSock::ReceiveNextValue, NLNET::CBufSock::SendNextValue, NLNET::CTcpSock::setNoDelay(), and NLNET::CBufSock::Sock. Referenced by NLNET::CCallbackClient::connect(), and NLNET::CBufClient::connect().
00296 { 00297 nlassert (this != InvalidSockId); // invalid bufsock 00298 nlassert( ! Sock->connected() ); 00299 00300 SendNextValue = ReceiveNextValue = 0; 00301 00302 Sock->connect( addr ); 00303 _ConnectedState = connectedstate; 00304 _KnowConnected = connectedstate; 00305 if ( nodelay ) 00306 { 00307 Sock->setNoDelay( true ); 00308 } 00309 } |
|
Returns the "logically connected" state (changed when processing a connection/disconnection callback).
Definition at line 237 of file buf_sock.h. References NLNET::CBufSock::_ConnectedState. Referenced by NLNET::CBufClient::connected(), NLNET::CCallbackClient::disconnect(), NLNET::CBufClient::disconnect(), and NLNET::CBufClient::~CBufClient().
00237 { return _ConnectedState; }
|
|
Disconnects; set connectedstate to false if no disconnection advertising is needed.
Definition at line 315 of file buf_sock.cpp. References NLNET::CBufSock::_ConnectedState, NLNET::CBufSock::_KnowConnected, NLNET::CTcpSock::disconnect(), nlassert, NLNET::CBufSock::ReceiveNextValue, NLNET::CBufSock::SendNextValue, and NLNET::CBufSock::Sock. Referenced by NLNET::CBufClient::disconnect().
00316 { 00317 nlassert (this != InvalidSockId); // invalid bufsock 00318 Sock->disconnect(); 00319 _ConnectedState = connectedstate; 00320 _KnowConnected = connectedstate; 00321 00322 SendNextValue = ReceiveNextValue = 0; 00323 } |
|
Fill the event type byte at pos length()(for a client connection).
Definition at line 298 of file buf_sock.h. References NLNET::CNonBlockingBufSock::_ReceiveBuffer, and uint8. Referenced by NLNET::CClientReceiveTask::run().
00298 { _ReceiveBuffer[_Length] = (uint8)CBufNetBase::User; } |
|
Fill the sockid and the event type byte at the end of the buffer.
Definition at line 368 of file buf_sock.h. References NLNET::CNonBlockingBufSock::length(), NLNET::TSockId, and uint8. Referenced by NLNET::CServerReceiveTask::run().
00369 { 00370 memcpy( (&*_ReceiveBuffer.begin()) + length(), &sockId, sizeof(TSockId) ); 00371 _ReceiveBuffer[length() + sizeof(TSockId)] = (uint8)CBufNetBase::User; 00372 } |
|
Forces to send all data pending in the send queue
Definition at line 137 of file buf_sock.cpp. References NLNET::CBufSock::_ReadyToSendBuffer, NLNET::CBufSock::_RTSBIndex, NLNET::CBufSock::asString(), NLMISC::CObjectVector< uint8 >::clear(), NLMISC::CBufFIFO::empty(), NLMISC::CBufFIFO::front(), NLMISC::CObjectVector< uint8 >::getPtr(), len, nlassert, nlassertex, nldebug, NLMISC::CBufFIFO::pop(), res, NLMISC::CObjectVector< uint8 >::resize(), NLNET::CSock::send(), NLNET::CBufSock::SendFifo, NLMISC::CObjectVector< uint8 >::size(), size, NLNET::CBufSock::Sock, NLNET::TBlockSize, uint, uint32, and uint8. Referenced by NLNET::CBufServer::disconnect(), NLNET::CBufClient::disconnect(), NLNET::CBufServer::flush(), NLNET::CBufClient::flush(), and NLNET::CBufSock::update().
00138 { 00139 nlassert (this != InvalidSockId); // invalid bufsock 00140 //nlnettrace( "CBufSock::flush" ); 00141 00142 // Copy data from the send queue to _ReadyToSendBuffer 00143 TBlockSize netlen; 00144 // vector<uint8> tmpbuffer; 00145 00146 // Process each element in the send queue 00147 while ( ! SendFifo.empty() ) 00148 { 00149 uint8 *tmpbuffer; 00150 uint32 size; 00151 SendFifo.front( tmpbuffer, size ); 00152 00153 // Compute the size and add it into the beginning of the buffer 00154 netlen = htonl( (TBlockSize)size ); 00155 uint32 oldBufferSize = _ReadyToSendBuffer.size(); 00156 _ReadyToSendBuffer.resize (oldBufferSize+sizeof(TBlockSize)+size); 00157 *(TBlockSize*)&(_ReadyToSendBuffer[oldBufferSize])=netlen; 00158 //nldebug( "O-%u %u+L%u (0x%x)", Sock->descriptor(), oldBufferSize, size, size ); 00159 00160 00161 // Append the temporary buffer to the global buffer 00162 CFastMem::memcpy (&_ReadyToSendBuffer[oldBufferSize+sizeof(TBlockSize)], tmpbuffer, size); 00163 SendFifo.pop(); 00164 } 00165 00166 // Actual sending of _ReadyToSendBuffer 00167 //if ( ! _ReadyToSendBuffer.empty() ) 00168 if ( _ReadyToSendBuffer.size() != 0 ) 00169 { 00170 // Send 00171 CSock::TSockResult res; 00172 TBlockSize len = _ReadyToSendBuffer.size() - _RTSBIndex; 00173 00174 res = Sock->send( _ReadyToSendBuffer.getPtr()+_RTSBIndex, len, false ); 00175 00176 if ( res == CSock::Ok ) 00177 { 00178 /* // Debug display 00179 switch ( _FlushTrigger ) 00180 { 00181 case FTTime : nldebug( "LNETL1: Time triggered flush for %s:", asString().c_str() ); break; 00182 case FTSize : nldebug( "LNETL1: Size triggered flush for %s:", asString().c_str() ); break; 00183 default: nldebug( "LNETL1: Manual flush for %s:", asString().c_str() ); 00184 } 00185 _FlushTrigger = FTManual; 00186 nldebug( "LNETL1: %s sent effectively a buffer (%d on %d B)", asString().c_str(), len, _ReadyToSendBuffer.size() ); 00187 */ 00188 00189 // TODO OPTIM remove the nldebug for speed 00190 //commented for optimisation nldebug( "LNETL1: %s sent effectively %u/%u bytes (pos %u wantedsend %u)", asString().c_str(), len, _ReadyToSendBuffer.size(), _RTSBIndex, realLen/*, stringFromVectorPart(_ReadyToSendBuffer,_RTSBIndex,len).c_str()*/ ); 00191 00192 if ( _RTSBIndex+len == _ReadyToSendBuffer.size() ) // for non-blocking mode 00193 { 00194 // If sending is ok, clear the global buffer 00195 //nldebug( "O-%u all %u bytes (%u to %u) sent", Sock->descriptor(), len, _RTSBIndex, _ReadyToSendBuffer.size() ); 00196 _ReadyToSendBuffer.clear(); 00197 _RTSBIndex = 0; 00198 } 00199 else 00200 { 00201 // Or clear only the data that was actually sent 00202 nlassertex( _RTSBIndex+len < _ReadyToSendBuffer.size(), ("index=%u len=%u size=%u", _RTSBIndex, len, _ReadyToSendBuffer.size()) ); 00203 //nldebug( "O-%u only %u B on %u (%u to %u) sent", Sock->descriptor(), len, _ReadyToSendBuffer.size()-_RTSBIndex, _RTSBIndex, _ReadyToSendBuffer.size() ); 00204 _RTSBIndex += len; 00205 if ( _ReadyToSendBuffer.size() > 20480 ) // if big, clear data already sent 00206 { 00207 uint nbcpy = _ReadyToSendBuffer.size() - _RTSBIndex; 00208 for (uint i = 0; i < nbcpy; i++) 00209 { 00210 _ReadyToSendBuffer[i] = _ReadyToSendBuffer[i+_RTSBIndex]; 00211 } 00212 _ReadyToSendBuffer.resize(nbcpy); 00213 //_ReadyToSendBuffer.erase( _ReadyToSendBuffer.begin(), _ReadyToSendBuffer.begin()+_RTSBIndex ); 00214 _RTSBIndex = 0; 00215 //nldebug( "O-%u Cleared data already sent, %u B remain", Sock->descriptor(), nbcpy ); 00216 } 00217 } 00218 } 00219 else 00220 { 00221 #ifdef NL_DEBUG 00222 // can happen in a normal behavior if, for example, the other side is not connected anymore 00223 nldebug( "LNETL1: %s failed to send effectively a buffer of %d bytes", asString().c_str(), _ReadyToSendBuffer.size() ); 00224 #endif 00225 return false; 00226 } 00227 } 00228 00229 return true; 00230 } |
|
Return the length of the received block (call after receivePart() returns true). The total size of received buffer is length() + nbExtraBytes (passed to receivePart()). Definition at line 303 of file buf_sock.h. References uint32. Referenced by fillSockIdAndEventType().
00303 { return _Length; }
|
|
Returns the task that "owns" the CServerBufSock object.
Definition at line 354 of file buf_sock.h. References _OwnerTask.
00354 { return _OwnerTask; } |
|
Pushes a buffer to the send queue and update, or returns false if the socket is not physically connected the or an error occured during sending Definition at line 178 of file buf_sock.h. References buffer, NLNET::CSock::connected(), nlassert, nlwarning, NLMISC::CBufFIFO::push(), res, NLNET::CBufSock::SendFifo, NLNET::CBufSock::Sock, uint32, and NLNET::CBufSock::update(). Referenced by NLNET::CBufServer::pushBufferToHost(), and NLNET::CBufClient::send().
00179 { 00180 nlassert (this != InvalidSockId); // invalid bufsock 00181 // nldebug( "LNETL1: Pushing buffer to %s", asString().c_str() ); 00182 00183 static uint32 biggerBufferSize = 64000; 00184 if (buffer.length() > biggerBufferSize) 00185 { 00186 biggerBufferSize = buffer.length(); 00187 nlwarning ("LNETL1: new record! bigger network message pushed (sent) is %u bytes", biggerBufferSize); 00188 } 00189 00190 if ( Sock->connected() ) 00191 { 00192 // Push into host's send queue 00193 SendFifo.push( buffer ); 00194 00195 // Update sending 00196 bool res = update (); 00197 return res; // not checking the result as in CBufServer::update() 00198 } 00199 return false; 00200 } |
|
Returns the filled buffer (call after receivePart() returns true). Its size is length()+1. Definition at line 308 of file buf_sock.h. References NLNET::CNonBlockingBufSock::_ReceiveBuffer, and nlnettrace. Referenced by NLNET::CServerReceiveTask::run(), and NLNET::CClientReceiveTask::run().
00308 { nlnettrace( "CServerBufSock::receivedBuffer" ); return _ReceiveBuffer; } |
|
Receives a part of a message (nonblocking socket only)
Definition at line 386 of file buf_sock.cpp. References NLNET::CNonBlockingBufSock::_BytesRead, NLNET::CNonBlockingBufSock::_NowReadingBuffer, NLNET::CNonBlockingBufSock::_ReceiveBuffer, NLNET::CInetAddress::asString(), NLNET::CBufSock::asString(), nlassert, nldebug, nlnettrace, nlwarning, NLNET::CSock::receive(), NLNET::CSock::remoteAddr(), NLMISC::stringFromVector(), NLNET::TBlockSize, NLMISC::toString(), uint32, and uint8. Referenced by NLNET::CServerReceiveTask::run(), and NLNET::CClientReceiveTask::run().
00387 { 00388 nlassert (this != InvalidSockId); // invalid bufsock 00389 nlnettrace( "CNonBlockingBufSock::receivePart" ); 00390 00391 TBlockSize actuallen; 00392 if ( ! _NowReadingBuffer ) 00393 { 00394 // Receiving length prefix 00395 actuallen = sizeof(_Length)-_BytesRead; 00396 Sock->receive( (uint8*)(&_Length)+_BytesRead, actuallen ); 00397 _BytesRead += actuallen; 00398 if ( _BytesRead == sizeof(_Length ) ) 00399 { 00400 if ( _Length != 0 ) 00401 { 00402 _Length = ntohl( _Length ); 00403 //nldebug( "I-%u L%u (0x%x) a%u", Sock->descriptor(), _Length, _Length, actuallen ); 00404 00405 // Test size limit 00406 if ( _Length > _MaxExpectedBlockSize ) 00407 { 00408 nlwarning( "LNETL1: Socket %s received header length %u exceeding max expected %u... Disconnecting", asString().c_str(), _Length, _MaxExpectedBlockSize ); 00409 throw ESocket( toString( "Received length %u exceeding max expected %u from %s", _Length, _MaxExpectedBlockSize, Sock->remoteAddr().asString().c_str() ).c_str(), false ); 00410 } 00411 00412 _NowReadingBuffer = true; 00413 _ReceiveBuffer.resize( _Length + nbExtraBytes ); 00414 } 00415 else 00416 { 00417 nlwarning( "LNETL1: Socket %s received null length in block header", asString().c_str() ); 00418 } 00419 _BytesRead = 0; 00420 } 00421 } 00422 00423 if ( _NowReadingBuffer ) 00424 { 00425 // Receiving payload buffer 00426 actuallen = _Length-_BytesRead; 00427 Sock->receive( &*_ReceiveBuffer.begin()+_BytesRead, actuallen ); 00428 _BytesRead += actuallen; 00429 00430 if ( _BytesRead == _Length ) 00431 { 00432 #ifdef NL_DEBUG 00433 nldebug( "LNETL1: %s received buffer (%u bytes): [%s]", asString().c_str(), _ReceiveBuffer.size(), stringFromVector(_ReceiveBuffer).c_str() ); 00434 #endif 00435 _NowReadingBuffer = false; 00436 //nldebug( "I-%u all %u B on %u", Sock->descriptor(), actuallen ); 00437 _BytesRead = 0; 00438 return true; 00439 } 00440 //else 00441 //{ 00442 // nldebug( "I-%u only %u B on %u", actuallen, Sock->descriptor(), _Length-(_BytesRead-actuallen) ); 00443 //} 00444 } 00445 00446 return false; 00447 } |
|
Sets the application identifier.
Definition at line 60 of file buf_sock.h. References NLNET::CBufSock::_AppId, and uint64. Referenced by NLNET::CUnifiedNetwork::addService(), NLNET::CPacsClient::connect(), and NLNET::CUnifiedNetwork::CUnifiedConnection::TConnection::setAppId().
00060 { _AppId = id; }
|
|
Sets the "logically connected" state (changed when processing a connection/disconnection callback).
Definition at line 234 of file buf_sock.h. References NLNET::CBufSock::_ConnectedState. Referenced by NLNET::CBufServer::dataAvailable(), and NLNET::CBufClient::dataAvailable().
00234 { _ConnectedState = connectedstate; } |
|
Set the size limit for received blocks.
Definition at line 289 of file buf_sock.h. References sint32. Referenced by NLNET::CBufClient::connect(), and NLNET::CListenTask::run().
00289 { _MaxExpectedBlockSize = limit; } |
|
Call this method after connecting (for a client connection) to set the non-blocking mode. For a server connection, call it as soon as the object is constructed Definition at line 286 of file buf_sock.h. References NLNET::CSock::setNonBlockingMode(). Referenced by NLNET::CBufClient::connect(), and NLNET::CListenTask::run().
00286 { Sock->setNonBlockingMode( true ); } |
|
Sets the task that "owns" the CServerBufSock object.
Definition at line 351 of file buf_sock.h. References _OwnerTask. Referenced by NLNET::CBufServer::addNewThread(), and NLNET::CBufServer::dispatchNewSocket().
00351 { _OwnerTask = owner; } |
|
Sets the size flush trigger. When the size of the send queue reaches or exceeds this calue, all data in the send queue is automatically sent (-1 to disable this trigger ) Definition at line 104 of file buf_sock.h. References NLNET::CBufSock::_TriggerSize, sint32, and size. Referenced by NLNET::CBufServer::setSizeFlushTrigger(), and NLNET::CBufClient::setSizeFlushTrigger().
00104 { _TriggerSize = size; } |
|
Sets the time flush trigger (in millisecond). When this time is elapsed, all data in the send queue is automatically sent (-1 to disable this trigger) Definition at line 236 of file buf_sock.cpp. References NLNET::CBufSock::_LastFlushTime, NLNET::CBufSock::_TriggerTime, nlassert, and sint32. Referenced by NLNET::CBufServer::setTimeFlushTrigger(), and NLNET::CBufClient::setTimeFlushTrigger().
00237 { 00238 nlassert (this != InvalidSockId); // invalid bufsock 00239 _TriggerTime = ms; 00240 _LastFlushTime = CTime::getLocalTime(); 00241 } |
|
Returns "SRV " (server).
Reimplemented from NLNET::CBufSock. Definition at line 365 of file buf_sock.h.
00365 { return "SRV "; } |
|
Update the network sending (call this method evenly). Returns false if an error occured.
Definition at line 247 of file buf_sock.cpp. References NLNET::CBufSock::_LastFlushTime, NLNET::CBufSock::_TriggerSize, NLNET::CBufSock::_TriggerTime, NLNET::CBufSock::flush(), nlassert, NLNET::CBufSock::SendFifo, sint32, NLMISC::CBufFIFO::size(), and NLMISC::TTime. Referenced by NLNET::CBufSock::pushBuffer(), and NLNET::CBufClient::update().
00248 { 00249 nlassert (this != InvalidSockId); // invalid bufsock 00250 // nlnettrace( "CBufSock::update-BEGIN" ); 00251 // Time trigger 00252 00253 if ( _TriggerTime != -1 ) 00254 { 00255 TTime now = CTime::getLocalTime(); 00256 if ( (sint32)(now-_LastFlushTime) >= _TriggerTime ) 00257 { 00258 #ifdef NL_DEBUG 00259 _FlushTrigger = FTTime; 00260 #endif 00261 if ( flush() ) 00262 { 00263 _LastFlushTime = now; 00264 // nlnettrace ( "CBufSock::update-END time 1" ); 00265 return true; 00266 } 00267 else 00268 { 00269 // nlnettrace ( "CBufSock::update-END time 0" ); 00270 return false; 00271 } 00272 } 00273 } 00274 // Size trigger 00275 if ( _TriggerSize != -1 ) 00276 { 00277 if ( (sint32)SendFifo.size() > _TriggerSize ) 00278 { 00279 #ifdef NL_DEBUG 00280 _FlushTrigger = FTSize; 00281 #endif 00282 // nlnettrace( "CBufSock::update-END size" ); 00283 return flush(); 00284 } 00285 } 00286 // nlnettrace( "CBufSock::update-END nosend" ); 00287 return true; 00288 } |
|
Reimplemented from NLNET::CBufSock. Definition at line 277 of file buf_sock.h. |
|
Reimplemented from NLNET::CBufSock. Definition at line 341 of file buf_sock.h. |
|
Definition at line 83 of file buf_sock.h. |
|
Definition at line 85 of file buf_sock.h. |
|
Definition at line 84 of file buf_sock.h. |
|
Reimplemented from NLNET::CBufSock. Definition at line 278 of file buf_sock.h. |
|
Definition at line 342 of file buf_sock.h. |
|
Reimplemented from NLNET::CBufSock. Definition at line 343 of file buf_sock.h. |
|
True after a connection callback has been sent to the user, for this connection.
Definition at line 377 of file buf_sock.h. |
|
Definition at line 246 of file buf_sock.h. Referenced by NLNET::CBufSock::advertiseDisconnection(), NLNET::CBufSock::connect(), NLNET::CBufSock::disconnect(), and NLNET::CBufSock::~CBufSock(). |
|
Definition at line 314 of file buf_sock.h. |
|
Definition at line 380 of file buf_sock.h. Referenced by ownerTask(), and setOwnerTask(). |
|
Definition at line 311 of file buf_sock.h. Referenced by NLNET::CNonBlockingBufSock::fillEventTypeOnly(), NLNET::CNonBlockingBufSock::receivedBuffer(), and NLNET::CNonBlockingBufSock::receivePart(). |
|
Little tricky but this string is used by Layer4 to know which callback is authorized. This is empty when all callback are authorized. Definition at line 70 of file buf_sock.h. Referenced by NLNET::CCallbackNetBase::authorizeOnly(), NLNET::CCallbackNetBase::processOneMessage(), and NLNET::CBufSock::~CBufSock(). |
|
Definition at line 74 of file buf_sock.h. Referenced by NLNET::CBufSock::connect(), and NLNET::CBufSock::disconnect(). |
|
|
Definition at line 74 of file buf_sock.h. Referenced by NLNET::CBufSock::connect(), NLNET::CBufSock::disconnect(), and NLNET::CBufServer::send(). |
|