mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-14 08:01:38 +01:00
Set a disconn timer when somebody leaves to make it parallel with case
where somebody never shows up; print more info about cref state to ctrl port.
This commit is contained in:
parent
8edf8a5382
commit
7b04db43ae
1 changed files with 23 additions and 2 deletions
|
@ -422,14 +422,18 @@ CookieRef::handleEvents()
|
|||
case XWA_TIMERDISCONN:
|
||||
disconnectSockets( 0, XWRELAY_ERROR_TIMEOUT );
|
||||
break;
|
||||
|
||||
case XWA_HEARTDISCONN:
|
||||
notifyOthers( evt.u.heart.socket, XWRELAY_DISCONNECT_OTHER,
|
||||
XWRELAY_ERROR_HEART_OTHER );
|
||||
setAllConnectedTimer();
|
||||
reducePlayerCounts( evt.u.discon.socket );
|
||||
disconnectSockets( evt.u.heart.socket,
|
||||
XWRELAY_ERROR_HEART_YOU );
|
||||
break;
|
||||
|
||||
case XWA_DISCONNECT:
|
||||
setAllConnectedTimer();
|
||||
reducePlayerCounts( evt.u.discon.socket );
|
||||
removeSocket( evt.u.discon.socket );
|
||||
/* Don't notify. This is a normal part of a game ending. */
|
||||
|
@ -444,6 +448,7 @@ CookieRef::handleEvents()
|
|||
break;
|
||||
|
||||
case XWA_REMOVESOCKET:
|
||||
setAllConnectedTimer();
|
||||
reducePlayerCounts( evt.u.rmsock.socket );
|
||||
notifyOthers( evt.u.rmsock.socket, XWRELAY_DISCONNECT_OTHER,
|
||||
XWRELAY_ERROR_LOST_OTHER );
|
||||
|
@ -800,9 +805,25 @@ CookieRef::_PrintCookieInfo( string& out )
|
|||
snprintf( buf, sizeof(buf), "Players here=%d\n", m_nPlayersHere );
|
||||
out += buf;
|
||||
|
||||
snprintf( buf, sizeof(buf), "State=%s\n", stateString( m_curState ) );
|
||||
out += buf;
|
||||
|
||||
/* Timer state: how long since last heartbeat; how long til disconn timer
|
||||
fires. */
|
||||
|
||||
/* n messages */
|
||||
/* n bytes */
|
||||
/* open since when */
|
||||
/* sockets */
|
||||
|
||||
snprintf( buf, sizeof(buf), "Hosts connected=%d; cur time = %ld\n",
|
||||
m_sockets.size(), now() );
|
||||
out += buf;
|
||||
map<HostID,HostRec>::iterator iter = m_sockets.begin();
|
||||
while ( iter != m_sockets.end() ) {
|
||||
snprintf( buf, sizeof(buf), " HostID=%d; socket=%d;last hbeat=%ld\n",
|
||||
iter->first, iter->second.m_socket,
|
||||
iter->second.m_lastHeartbeat );
|
||||
out += buf;
|
||||
++iter;
|
||||
}
|
||||
|
||||
} /* PrintCookieInfo */
|
||||
|
|
Loading…
Reference in a new issue