[wpdev-commits] wolfpack/network uosocket.cpp,1.288,1.289 uosocket.h,1.95,1.96
Brought to you by:
rip,
thiagocorrea
|
From: <dar...@us...> - 2003-09-14 16:09:33
|
Update of /cvsroot/wpdev/wolfpack/network
In directory sc8-pr-cvs1:/tmp/cvs-serv19012/network
Modified Files:
uosocket.cpp uosocket.h
Log Message:
Revised idle logout behaviour.
Index: uosocket.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/network/uosocket.cpp,v
retrieving revision 1.288
retrieving revision 1.289
diff -C2 -d -r1.288 -r1.289
*** uosocket.cpp 13 Sep 2003 13:37:16 -0000 1.288
--- uosocket.cpp 14 Sep 2003 16:09:01 -0000 1.289
***************
*** 103,106 ****
--- 103,109 ----
_uniqueId = sDevice->socket();
tooltipscache_ = new QBitArray;
+
+ // Creation of a new socket counts as activity
+ _lastActivity = getNormalizedTime();
}
***************
*** 191,202 ****
Q_UINT8 packetId = (*packet)[0];
- // After two pings we idle-disconnect
- if( lastPacket == 0x73 && packetId == 0x73 )
- {
- log( "Disconnected idling socket.\n" );
- disconnect();
- return;
- }
-
// Disconnect harmful clients
if( ( _account < 0 ) && ( packetId != 0x80 ) && ( packetId != 0x91 ) )
--- 194,197 ----
***************
*** 217,223 ****
_state = LoggedIn;
- if( _player )
- _player->setClientIdleTime( uiCurrentTime + 120 * MY_CLOCKS_PER_SEC );
-
// Relay it to the handler functions
switch( packetId )
--- 212,215 ----
***************
*** 301,306 ****
default:
Console::instance()->send( packet->dump( packet->uncompressed() ) );
! break;
}
delete packet;
--- 293,302 ----
default:
Console::instance()->send( packet->dump( packet->uncompressed() ) );
! delete packet;
! return;
}
+
+ // We received a packet we know
+ _lastActivity = getNormalizedTime();
delete packet;
***************
*** 1269,1273 ****
}
- _player->setClientIdleTime( uiCurrentTime + 300 * 1000 );
_state = InGame;
}
--- 1265,1268 ----
***************
*** 1622,1626 ****
void cUOSocket::poll()
{
! // TODO: check for timed out target requests herei
if( targetRequest && targetRequest->timeout() > 1 && targetRequest->timeout() < uiCurrentTime )
{
--- 1617,1621 ----
void cUOSocket::poll()
{
! // Check for timed out target requests
if( targetRequest && targetRequest->timeout() > 1 && targetRequest->timeout() < uiCurrentTime )
{
***************
*** 1629,1632 ****
--- 1624,1634 ----
targetRequest = 0;
cancelTarget();
+ }
+
+ // Check for idling/silent sockets
+ if( _lastActivity + 180 * MY_CLOCKS_PER_SEC < uiCurrentTime )
+ {
+ log( QString( "Idle for %1 ms. Disconnecting.\n" ).arg( uiCurrentTime - _lastActivity ) );
+ disconnect();
}
}
Index: uosocket.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/network/uosocket.h,v
retrieving revision 1.95
retrieving revision 1.96
diff -C2 -d -r1.95 -r1.96
*** uosocket.h 9 Sep 2003 23:09:31 -0000 1.95
--- uosocket.h 14 Sep 2003 16:09:01 -0000 1.96
***************
*** 71,75 ****
private:
QSocketDevice *_socket;
! UINT32 _rxBytes, _txBytes, _uniqueId;
cAccount* _account;
P_PLAYER _player;
--- 71,75 ----
private:
QSocketDevice *_socket;
! unsigned int _rxBytes, _txBytes, _uniqueId, _lastActivity;
cAccount* _account;
P_PLAYER _player;
***************
*** 119,127 ****
! Q_UINT32 rxBytes( void ) const;
! Q_UINT32 txBytes( void ) const;
! Q_UINT8 viewRange( void ) const;
! void setRxBytes( Q_UINT32 data );
! void setTxBytes( Q_UINT32 data );
Q_UINT32 uniqueId( void ) const;
--- 119,128 ----
! unsigned int lastActivity() const;
! unsigned int rxBytes() const;
! unsigned int txBytes() const;
! unsigned char viewRange() const;
! void setRxBytes( unsigned int data );
! void setTxBytes( unsigned int data );
Q_UINT32 uniqueId( void ) const;
***************
*** 268,272 ****
}
! inline Q_UINT32 cUOSocket::rxBytes( void ) const
{
return _rxBytes;
--- 269,278 ----
}
! inline unsigned int cUOSocket::lastActivity() const
! {
! return _lastActivity;
! }
!
! inline unsigned int cUOSocket::rxBytes( void ) const
{
return _rxBytes;
|