mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-26 09:58:20 +01:00
make linux app handle sendChat cmd
This commit is contained in:
parent
c198d2d0ca
commit
74abdfb26c
3 changed files with 25 additions and 1 deletions
|
@ -729,7 +729,7 @@ cb_makeMoveIf( CursesBoardState* cbState, XP_U32 gameID )
|
|||
success = board_canHint( board );
|
||||
if ( success ) {
|
||||
XP_Bool ignored;
|
||||
success = board_requestHint( cGlobals->game.board, NULL_XWE,
|
||||
success = board_requestHint( board, NULL_XWE,
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
XP_FALSE,
|
||||
#endif
|
||||
|
@ -745,6 +745,18 @@ cb_makeMoveIf( CursesBoardState* cbState, XP_U32 gameID )
|
|||
return success;
|
||||
}
|
||||
|
||||
XP_Bool
|
||||
cb_sendChat( CursesBoardState* cbState, XP_U32 gameID, const char* msg )
|
||||
{
|
||||
CursesBoardGlobals* bGlobals =
|
||||
findOrOpenForGameID( cbState, gameID, NULL, NULL );
|
||||
XP_Bool success = !!bGlobals;
|
||||
if ( success ) {
|
||||
board_sendChat( bGlobals->cGlobals.game.board, NULL_XWE, msg );
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
static void
|
||||
kill_board( gpointer data )
|
||||
{
|
||||
|
|
|
@ -56,6 +56,7 @@ void cb_addInvites( CursesBoardState* cbState, XP_U32 gameID, XP_U16 nRemotes,
|
|||
XP_Bool cb_makeRematch( CursesBoardState* cbState, XP_U32 gameID,
|
||||
RematchOrder ro, XP_U32* newGameID );
|
||||
XP_Bool cb_makeMoveIf( CursesBoardState* cbState, XP_U32 gameID );
|
||||
XP_Bool cb_sendChat( CursesBoardState* cbState, XP_U32 gameID, const char* msg );
|
||||
|
||||
const CommonGlobals* cb_getForGameID( CursesBoardState* cbState, XP_U32 gameID );
|
||||
|
||||
|
|
|
@ -1596,6 +1596,15 @@ moveifFromArgs( CursesAppGlobals* aGlobals, cJSON* args )
|
|||
return cb_makeMoveIf( aGlobals->cbState, gameID );
|
||||
}
|
||||
|
||||
static XP_Bool
|
||||
chatFromArgs( CursesAppGlobals* aGlobals, cJSON* args )
|
||||
{
|
||||
XP_U32 gameID = gidFromObject( args );
|
||||
cJSON* tmp = cJSON_GetObjectItem( args, "msg" );
|
||||
const char* msg = tmp->valuestring;
|
||||
return cb_sendChat( aGlobals->cbState, gameID, msg );
|
||||
}
|
||||
|
||||
/* Return 'gid' of new game */
|
||||
static XP_U32
|
||||
rematchFromArgs( CursesAppGlobals* aGlobals, cJSON* args )
|
||||
|
@ -1800,6 +1809,8 @@ on_incoming_signal( GSocketService* XP_UNUSED(service),
|
|||
} else if ( 0 == strcmp( cmdStr, "getPlayers" ) ) {
|
||||
cJSON* players = getPlayersForArgs( aGlobals, args );
|
||||
addObjectToObject( &response, "players", players );
|
||||
} else if ( 0 == strcmp( cmdStr, "sendChat" ) ) {
|
||||
success = chatFromArgs( aGlobals, args );
|
||||
} else {
|
||||
success = XP_FALSE;
|
||||
XP_ASSERT(0);
|
||||
|
|
Loading…
Reference in a new issue