don't pile on chat messages when relay isn't even connected: it's an

unfair test that doesn't duplicate what users will likely do.
This commit is contained in:
Eric House 2013-07-01 07:51:38 -07:00 committed by Eric House
parent 3d18e5832e
commit 9fca3792cf
3 changed files with 7 additions and 9 deletions

View file

@ -1661,9 +1661,10 @@ relay_sendNoConn_curses( const XP_U8* msg, XP_U16 len,
} /* relay_sendNoConn_curses */ } /* relay_sendNoConn_curses */
static void static void
relay_status_curses( void* XP_UNUSED(closure), relay_status_curses( void* closure, CommsRelayState state )
CommsRelayState XP_UNUSED_DBG(state) )
{ {
CursesAppGlobals* globals = (CursesAppGlobals*)closure;
globals->commsRelayState = state;
XP_LOGF( "%s got status: %s", __func__, CommsRelayState2Str(state) ); XP_LOGF( "%s got status: %s", __func__, CommsRelayState2Str(state) );
} }
@ -1720,22 +1721,20 @@ chatsTimerFired( gpointer data )
{ {
CursesAppGlobals* globals = (CursesAppGlobals*)data; CursesAppGlobals* globals = (CursesAppGlobals*)data;
GameStateInfo gsi; if ( COMMS_RELAYSTATE_ALLCONNECTED == globals->commsRelayState ) {
game_getState( &globals->cGlobals.game, &gsi );
if ( gsi.gameIsConnected ) {
XP_UCHAR msg[128]; XP_UCHAR msg[128];
struct tm* timp; struct tm* timp;
struct timeval tv; struct timeval tv;
struct timezone tz; struct timezone tz;
XP_LOGF( "%s: sending \"%s\"", __func__, msg );
gettimeofday( &tv, &tz ); gettimeofday( &tv, &tz );
timp = localtime( &tv.tv_sec ); timp = localtime( &tv.tv_sec );
snprintf( msg, sizeof(msg), "Saying hi via chat at %.2d:%.2d:%.2d", snprintf( msg, sizeof(msg), "Saying hi via chat at %.2d:%.2d:%.2d",
timp->tm_hour, timp->tm_min, timp->tm_sec ); timp->tm_hour, timp->tm_min, timp->tm_sec );
server_sendChat( globals->cGlobals.game.server, msg ); server_sendChat( globals->cGlobals.game.server, msg );
XP_LOGF( "%s: sent \"%s\"", __func__, msg );
} }
return TRUE; return TRUE;

View file

@ -81,6 +81,7 @@ struct CursesAppGlobals {
short statusLine; short statusLine;
XWGameState state; XWGameState state;
CommsRelayState commsRelayState;
struct sockaddr_in listenerSockAddr; struct sockaddr_in listenerSockAddr;
#ifdef USE_GLIBLOOP #ifdef USE_GLIBLOOP

View file

@ -48,8 +48,6 @@
# include <bluetooth/hci_lib.h> # include <bluetooth/hci_lib.h>
#endif #endif
/* #include <pthread.h> */
#include "linuxmain.h" #include "linuxmain.h"
#include "linuxutl.h" #include "linuxutl.h"
#include "linuxbt.h" #include "linuxbt.h"