enable invite by relayID (and rematch from gtk side)

This commit is contained in:
Eric House 2020-01-31 17:34:41 -08:00
parent d891d59fc9
commit cdcf63a0bf
4 changed files with 21 additions and 10 deletions

View file

@ -1,4 +1,4 @@
/* -*- compile-command: "make MEMDEBUG=TRUE -j3"; -*- */
/* -*- compile-command: "make MEMDEBUG=TRUE -j5"; -*- */
/*
* Copyright 2000 - 2020 by Eric House (xwords@eehouse.org). All rights
* reserved.
@ -1235,19 +1235,22 @@ handleInvite( void* closure, int XP_UNUSED(key) )
CommsCtxt* comms = cGlobals->game.comms;
XP_ASSERT( comms );
comms_getAddr( comms, &addr );
XP_U16 nPlayers = 1;
gint forceChannel = 1;
NetLaunchInfo nli = {0};
nli_init( &nli, cGlobals->gi, &addr, nPlayers, forceChannel );
if ( SERVER_ISSERVER != cGlobals->gi->serverRole ) {
ca_inform( bGlobals->boardWin, "Only hosts can invite" );
} else if ( !params->connInfo.sms.inviteePhone ) {
ca_inform( bGlobals->boardWin, "No way to invite; use --invitee-sms-number" );
} else {
} else if ( 0 != params->connInfo.relay.inviteeRelayID ) {
relaycon_invite( params, params->connInfo.relay.inviteeRelayID, NULL, &nli );
} else if ( !!params->connInfo.sms.inviteePhone ) {
/* These should both be settable/derivable */
XP_U16 nPlayers = 1;
gint forceChannel = 1;
NetLaunchInfo nli = {0};
nli_init( &nli, cGlobals->gi, &addr, nPlayers, forceChannel );
linux_sms_invite( params, &nli, params->connInfo.sms.inviteePhone,
params->connInfo.sms.port );
} else {
ca_inform( bGlobals->boardWin, "No way to invite; use --invitee-sms-number or --invitee-relayid" );
}
return XP_TRUE;
}

View file

@ -1448,13 +1448,14 @@ send_invites( CommonGlobals* cGlobals, XP_U16 nPlayers,
}
#endif
if ( '\0' != addrs->u.sms.phone[0] && 0 < addrs->u.sms.port ) {
if ( !!addrs && '\0' != addrs->u.sms.phone[0] && 0 < addrs->u.sms.port ) {
gchar gameName[64];
snprintf( gameName, VSIZE(gameName), "Game %d", cGlobals->gi->gameID );
linux_sms_invite( cGlobals->params, &nli,
addrs->u.sms.phone, addrs->u.sms.port );
}
if ( 0 != relayDevID || !!relayID ) {
XP_ASSERT( 0 != relayDevID || (!!relayID && !!relayID[0]) );
relaycon_invite( cGlobals->params, relayDevID, relayID, &nli );

View file

@ -860,6 +860,7 @@ typedef enum {
,CMD_JOINADVERTISED
,CMD_PHONIES
,CMD_BONUSFILE
,CMD_INVITEE_RELAYID
#endif
#ifdef XWFEATURE_BLUETOOTH
,CMD_BTADDR
@ -991,6 +992,7 @@ static CmdInfoRec CmdInfoRecs[] = {
"ignore (0, default), warn (1) or lose turn (2)" }
,{ CMD_BONUSFILE, true, "bonus-file",
"provides bonus info: . + * ^ and ! are legal" }
,{ CMD_INVITEE_RELAYID, true, "invitee-relayid", "relayID to send any invitation to" }
#endif
#ifdef XWFEATURE_BLUETOOTH
,{ CMD_BTADDR, true, "btaddr", "bluetooth address of host" }
@ -2624,6 +2626,10 @@ main( int argc, char** argv )
case CMD_BONUSFILE:
mainParams.bonusFile = optarg;
break;
case CMD_INVITEE_RELAYID:
mainParams.connInfo.relay.inviteeRelayID = atoi(optarg);
addr_addType( &mainParams.addr, COMMS_CONN_RELAY );
break;
#endif
case CMD_CLOSESTDIN:
mainParams.closeStdin = XP_TRUE;

View file

@ -139,6 +139,7 @@ typedef struct LaunchParams {
short defaultSendPort;
XP_Bool seeksPublicRoom;
XP_Bool advertiseRoom;
XP_U32 inviteeRelayID;
} relay;
#endif
#ifdef XWFEATURE_BLUETOOTH