fix to compile and allow invites too late

The curses test scripts keep sending invitations, so don't assert
that's not true.
This commit is contained in:
Eric House 2022-09-06 13:58:36 -07:00
parent 16857ab74a
commit 98184b9e47
3 changed files with 52 additions and 69 deletions

View file

@ -1558,12 +1558,12 @@ comms_invite( CommsCtxt* comms, XWEnv xwe, const NetLaunchInfo* nli,
for ( MsgQueueElem* elem = comms->msgQueueHead; !!elem; elem = elem-> next ) {
if ( channelNo == elem->channelNo ) {
XP_ASSERT( 0 == elem->msgID );
XP_ASSERT( 0 != channelNo );
if ( 0 == elem->msgID && 0 != channelNo ) {
freeElem( comms, elem );
XP_LOGFF( "nuked old invite" );
}
}
}
if ( 0 == channelNo ) {
channelNo = comms_getChannelSeed(comms) & ~CHANNEL_MASK;
@ -1914,48 +1914,34 @@ sendMsg( CommsCtxt* comms, XWEnv xwe, MsgQueueElem* elem, const CommsConnType fi
break;
}
XP_ASSERT( !!comms->procs.send );
if ( 0 ) {
#ifdef XWFEATURE_COMMS_INVITE
} else if ( isInvite ) {
XP_ASSERT( !!comms->procs.sendInvt );
NetLaunchInfo* nli = (NetLaunchInfo*)elem->msg;
nSent = (*comms->procs.sendInvt)( xwe, nli, elem->createdStamp,
&addr, comms->procs.closure );
#endif
} else {
XP_ASSERT( !!comms->procs.sendMsg );
XP_U32 gameid = gameID( comms );
logAddr( comms, xwe, &addr, __func__ );
XP_UCHAR msgNo[16];
formatMsgNo( comms, elem, msgNo, sizeof(msgNo) );
nSent = (*comms->procs.send)( xwe, elem->msg, elem->len, msgNo,
nSent = (*comms->procs.sendMsg)( xwe, elem->msg, elem->len, msgNo,
elem->createdStamp, &addr,
typ, gameid, comms->procs.closure );
typ, gameid,
comms->procs.closure );
}
}
break;
}
/* <<<<<<< HEAD */
/* } /\* switch *\/ */
/* } */
/* XP_LOGFF( TAGFMT() "sent %d bytes using typ %s", TAGPRMS, nSent, */
/* ConnType2Str(typ) ); */
/* if ( nSent > result ) { */
/* result = nSent; */
/* ======= */
/* if ( 0 ) { */
/* #ifdef XWFEATURE_COMMS_INVITE */
/* } else if ( isInvite ) { */
/* XP_ASSERT( !!comms->procs.sendInvt ); */
/* NetLaunchInfo* nli = (NetLaunchInfo*)elem->msg; */
/* nSent = (*comms->procs.sendInvt)( xwe, nli, elem->createdStamp, */
/* &addr, comms->procs.closure ); */
/* #endif */
/* } else { */
/* XP_ASSERT( !!comms->procs.sendMsg ); */
/* XP_U32 gameid = gameID( comms ); */
/* logAddr( comms, xwe, &addr, __func__ ); */
/* XP_UCHAR msgNo[16]; */
/* formatMsgNo( comms, elem, msgNo, sizeof(msgNo) ); */
/* nSent = (*comms->procs.sendMsg)( xwe, elem->msg, elem->len, msgNo, */
/* elem->createdStamp, &addr, */
/* typ, gameid, */
/* comms->procs.closure ); */
/* } */
/* break; */
/* >>>>>>> d9781d21e (snapshot: mqtt invites for gtk work via comms) */
} /* switch */
}
if ( nSent > result ) {
result = nSent;
}
} /* for */
if ( result == elem->len ) {
#ifdef DEBUG

View file

@ -281,27 +281,21 @@ logNLI( const NetLaunchInfo* nli, const char* callerFunc, const int callerLine )
XP_UCHAR buf[1024];
XP_SNPRINTF( buf, VSIZE(buf), "{ctyps: [%s], nPlayersT: %d, nPlayersH: %d, "
/* <<<<<<< HEAD */
/* "isoCode: '%s', gameID: %d", */
/* conTypes, nli->nPlayersT, nli->nPlayersH, nli->isoCodeStr, */
/* nli->gameID ); */
/* if ( types_hasType( nli->_conTypes, COMMS_CONN_MQTT ) ) { */
/* XP_UCHAR smallBuf[128]; */
/* XP_SNPRINTF( smallBuf, VSIZE(smallBuf), ", mqttid: %s", nli->mqttDevID ); */
/* XP_STRCAT( buf, smallBuf ); */
/* } */
/* if ( types_hasType( nli->_conTypes, COMMS_CONN_SMS ) ) { */
/* XP_UCHAR smallBuf[128]; */
/* XP_SNPRINTF( smallBuf, VSIZE(smallBuf), ", phone: %s", */
/* nli->phone ); */
/* XP_STRCAT( buf, smallBuf ); */
/* } */
/* XP_STRCAT( buf, "}" ); */
/* ======= */
/* "isoCode: '%s', gameID: %d, inviteID: %s, mqttid: %s, phone: %s}", conTypes, */
/* nli->nPlayersT, nli->nPlayersH, nli->isoCodeStr, nli->gameID, */
/* nli->inviteID, nli->mqttDevID, nli->phone ); */
/* >>>>>>> cd0f0d95b (support comparing SMS addresses too) */
"isoCode: '%s', gameID: %d",
conTypes, nli->nPlayersT, nli->nPlayersH, nli->isoCodeStr,
nli->gameID );
if ( types_hasType( nli->_conTypes, COMMS_CONN_MQTT ) ) {
XP_UCHAR smallBuf[128];
XP_SNPRINTF( smallBuf, VSIZE(smallBuf), ", mqttid: %s", nli->mqttDevID );
XP_STRCAT( buf, smallBuf );
}
if ( types_hasType( nli->_conTypes, COMMS_CONN_SMS ) ) {
XP_UCHAR smallBuf[128];
XP_SNPRINTF( smallBuf, VSIZE(smallBuf), ", phone: %s",
nli->phone );
XP_STRCAT( buf, smallBuf );
}
XP_STRCAT( buf, "}" );
XP_LOGF( "%s", buf );
}
# endif

View file

@ -116,7 +116,7 @@ static bool handleReplace( void* closure, int key );
static bool handleRootKeyShow( void* closure, int key );
static bool handleRootKeyHide( void* closure, int key );
#endif
static bool handleInvite( void* closure, int key );
static bool sendInvite( void* closure, int key );
#ifdef XWFEATURE_RELAY
static void relay_connd_curses( XWEnv xwe, void* closure, XP_UCHAR* const room,
@ -168,7 +168,7 @@ inviteIdle( gpointer data )
|| !!params->connInfo.relay.inviteeRelayIDs
#endif
|| !!params->connInfo.mqtt.inviteeDevIDs ) {
handleInvite( bGlobals, 0 );
sendInvite( bGlobals, 0 );
}
return FALSE;
}
@ -255,7 +255,7 @@ const MenuList g_boardMenuList[] = {
{ handleUndo, "Undo prev", "U", 'U' },
{ handleReplace, "uNdo cur", "N", 'N' },
{ handleInvite, "invitE", "E", 'E' },
{ sendInvite, "invitE", "E", 'E' },
{ NULL, NULL, NULL, '\0'}
};
@ -1247,11 +1247,14 @@ inviteList( CommonGlobals* cGlobals, CommsAddrRec* myAddr, GSList* invitees,
#endif
}
}
if ( haveAddressees ) {
XP_LOGFF( "worked for %s", ConnType2Str( typ ) );
}
return haveAddressees;
}
static bool
handleInvite( void* closure, int XP_UNUSED(key) )
sendInvite( void* closure, int XP_UNUSED(key) )
{
CursesBoardGlobals* bGlobals = (CursesBoardGlobals*)closure;
CommonGlobals* cGlobals = &bGlobals->cGlobals;
@ -1286,7 +1289,7 @@ handleInvite( void* closure, int XP_UNUSED(key) )
} else if ( addr_hasType( &selfAddr, COMMS_CONN_SMS ) ) {
linux_sms_invite( params, &nli, selfAddr.u.sms.phone, selfAddr.u.sms.port );
} else if ( addr_hasType( &selfAddr, COMMS_CONN_MQTT ) ) {
mqttc_invite( params, &nli, mqttc_getDevID( params ) );
mqttc_invite( params, 0, &nli, mqttc_getDevID( params ) );
} else if ( addr_hasType( &selfAddr, COMMS_CONN_RELAY ) ) {
/* ======= */
/* } else if ( addr_hasType( &addr, COMMS_CONN_SMS ) ) { */