mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
add addrType to comms' main addr when added to channel
I'm fixing android client not showing stats for or allowing to disable mqtt after it's added automatically to a game that connects otherwise. Problem was that only the channel got the mqtt address flag. So now add the flag for any type that's added.
This commit is contained in:
parent
88dbc40180
commit
81799d3903
9 changed files with 64 additions and 27 deletions
|
@ -558,7 +558,8 @@ public class BTService extends XWJIService {
|
||||||
// listenUsingRfcommWithServiceRecord() in background (on
|
// listenUsingRfcommWithServiceRecord() in background (on
|
||||||
// Android 9)
|
// Android 9)
|
||||||
m_serverSocket = null;
|
m_serverSocket = null;
|
||||||
Log.ex( TAG, ex );
|
// I'm seeing too much of this on two-user systems.
|
||||||
|
// Log.ex( TAG, ex );
|
||||||
}
|
}
|
||||||
|
|
||||||
int nBadCount = 0;
|
int nBadCount = 0;
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class ConnViaViewLayout extends LinearLayout {
|
public class ConnViaViewLayout extends LinearLayout {
|
||||||
|
private static final String TAG = ConnViaViewLayout.class.getSimpleName();
|
||||||
private CommsConnTypeSet m_curSet;
|
private CommsConnTypeSet m_curSet;
|
||||||
private DlgDelegate.HasDlgDelegate m_dlgDlgt;
|
private DlgDelegate.HasDlgDelegate m_dlgDlgt;
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
|
|
|
@ -213,6 +213,20 @@ public class CommsAddrRec {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
if ( BuildConfig.NON_RELEASE ) {
|
||||||
|
List<String> tmp = new ArrayList<>();
|
||||||
|
for ( CommsConnType typ : getTypes() ) {
|
||||||
|
tmp.add( typ.toString() );
|
||||||
|
}
|
||||||
|
return TextUtils.join(",", tmp );
|
||||||
|
} else {
|
||||||
|
return super.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public String toString( Context context, boolean longVersion )
|
public String toString( Context context, boolean longVersion )
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
|
|
|
@ -603,7 +603,6 @@ addrTypesToJ( JNIEnv* env, const CommsAddrRec* addr )
|
||||||
"(Ljava/lang/Object;)Z" );
|
"(Ljava/lang/Object;)Z" );
|
||||||
XP_ASSERT( !!mid2 );
|
XP_ASSERT( !!mid2 );
|
||||||
CommsConnType typ;
|
CommsConnType typ;
|
||||||
/* far as it gets */
|
|
||||||
for ( XP_U32 st = 0; addr_iter( addr, &typ, &st ); ) {
|
for ( XP_U32 st = 0; addr_iter( addr, &typ, &st ); ) {
|
||||||
jobject jtyp = intToJEnum( env, typ,
|
jobject jtyp = intToJEnum( env, typ,
|
||||||
PKG_PATH("jni/CommsAddrRec$CommsConnType") );
|
PKG_PATH("jni/CommsAddrRec$CommsConnType") );
|
||||||
|
|
|
@ -2183,15 +2183,15 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
||||||
server_getDupTimerExpires(server) );
|
server_getDupTimerExpires(server) );
|
||||||
|
|
||||||
if ( !!state->game.comms ) {
|
if ( !!state->game.comms ) {
|
||||||
CommsAddrRec addr;
|
|
||||||
CommsCtxt* comms = state->game.comms;
|
CommsCtxt* comms = state->game.comms;
|
||||||
comms_getAddr( comms, &addr );
|
|
||||||
setInt( env, jsummary, "seed", comms_getChannelSeed( comms ) );
|
setInt( env, jsummary, "seed", comms_getChannelSeed( comms ) );
|
||||||
setInt( env, jsummary, "missingPlayers",
|
setInt( env, jsummary, "missingPlayers",
|
||||||
server_getMissingPlayers( server ) );
|
server_getMissingPlayers( server ) );
|
||||||
setInt( env, jsummary, "nPacketsPending",
|
setInt( env, jsummary, "nPacketsPending",
|
||||||
comms_countPendingPackets( state->game.comms ) );
|
comms_countPendingPackets( state->game.comms ) );
|
||||||
|
|
||||||
|
CommsAddrRec addr;
|
||||||
|
comms_getAddr( comms, &addr );
|
||||||
setTypeSetFieldIn( env, &addr, jsummary, "conTypes" );
|
setTypeSetFieldIn( env, &addr, jsummary, "conTypes" );
|
||||||
|
|
||||||
CommsConnType typ;
|
CommsConnType typ;
|
||||||
|
@ -2226,7 +2226,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1summarize
|
||||||
case COMMS_CONN_SMS: addrps[ii] = (XP_UCHAR*)&addrs[ii].u.sms.phone; break;
|
case COMMS_CONN_SMS: addrps[ii] = (XP_UCHAR*)&addrs[ii].u.sms.phone; break;
|
||||||
default: XP_ASSERT(0); break;
|
default: XP_ASSERT(0); break;
|
||||||
}
|
}
|
||||||
XP_LOGF( "%s: adding btaddr/phone/mac %s", __func__, addrps[ii] );
|
XP_LOGFF( "adding btaddr/phone/mac %s", addrps[ii] );
|
||||||
}
|
}
|
||||||
setStringArray( env, jsummary, "remoteDevs", count, addrps );
|
setStringArray( env, jsummary, "remoteDevs", count, addrps );
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,9 +194,10 @@ static AddressRecord* rememberChannelAddress( CommsCtxt* comms, XWEnv xwe,
|
||||||
XP_PlayerAddr channelNo,
|
XP_PlayerAddr channelNo,
|
||||||
XWHostID id,
|
XWHostID id,
|
||||||
const CommsAddrRec* addr );
|
const CommsAddrRec* addr );
|
||||||
static void augmentChannelAddr( AddressRecord* rec, const CommsAddrRec* addr,
|
static void augmentChannelAddr( CommsCtxt* comms, AddressRecord* rec,
|
||||||
XWHostID hostID );
|
const CommsAddrRec* addr, XWHostID hostID );
|
||||||
static void augmentAddr( CommsAddrRec* dest, const CommsAddrRec* src );
|
static void augmentAddr( CommsCtxt* comms, CommsAddrRec* dest,
|
||||||
|
const CommsAddrRec* src );
|
||||||
static XP_Bool channelToAddress( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo,
|
static XP_Bool channelToAddress( CommsCtxt* comms, XWEnv xwe, XP_PlayerAddr channelNo,
|
||||||
const CommsAddrRec** addr );
|
const CommsAddrRec** addr );
|
||||||
static AddressRecord* getRecordFor( CommsCtxt* comms, XWEnv xwe,
|
static AddressRecord* getRecordFor( CommsCtxt* comms, XWEnv xwe,
|
||||||
|
@ -1031,7 +1032,7 @@ comms_augmentHostAddr( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr )
|
||||||
&& ! addr_hasType( &comms->addr, COMMS_CONN_RELAY );
|
&& ! addr_hasType( &comms->addr, COMMS_CONN_RELAY );
|
||||||
|
|
||||||
CommsAddrRec tmp = comms->addr;
|
CommsAddrRec tmp = comms->addr;
|
||||||
augmentAddr( &tmp, addr );
|
augmentAddr( comms, &tmp, addr );
|
||||||
util_addrChange( comms->util, xwe, &comms->addr, &tmp );
|
util_addrChange( comms->util, xwe, &comms->addr, &tmp );
|
||||||
comms->addr = tmp;
|
comms->addr = tmp;
|
||||||
|
|
||||||
|
@ -1061,7 +1062,7 @@ comms_addMQTTDevID( CommsCtxt* comms, XP_PlayerAddr channelNo,
|
||||||
CommsAddrRec addr = {0};
|
CommsAddrRec addr = {0};
|
||||||
addr_setType( &addr, COMMS_CONN_MQTT );
|
addr_setType( &addr, COMMS_CONN_MQTT );
|
||||||
addr.u.mqtt.devID = *devID;
|
addr.u.mqtt.devID = *devID;
|
||||||
augmentAddr( &rec->addr, &addr );
|
augmentAddr( comms, &rec->addr, &addr );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !found ) {
|
if ( !found ) {
|
||||||
|
@ -2266,7 +2267,7 @@ validateInitialMessage( CommsCtxt* comms, XWEnv xwe,
|
||||||
XP_LOGF( TAGFMT() "looking at %s", TAGPRMS, cbuf );
|
XP_LOGF( TAGFMT() "looking at %s", TAGPRMS, cbuf );
|
||||||
rec = getRecordFor( comms, xwe, addr, *channelNo, XP_TRUE );
|
rec = getRecordFor( comms, xwe, addr, *channelNo, XP_TRUE );
|
||||||
if ( !!rec ) {
|
if ( !!rec ) {
|
||||||
augmentChannelAddr( rec, addr, senderID );
|
augmentChannelAddr( comms, rec, addr, senderID );
|
||||||
/* reject: we've already seen init message on channel */
|
/* reject: we've already seen init message on channel */
|
||||||
XP_LOGF( TAGFMT() "rejecting duplicate INIT message", TAGPRMS );
|
XP_LOGF( TAGFMT() "rejecting duplicate INIT message", TAGPRMS );
|
||||||
rec = NULL;
|
rec = NULL;
|
||||||
|
@ -2341,7 +2342,7 @@ validateChannelMessage( CommsCtxt* comms, XWEnv xwe, const CommsAddrRec* addr,
|
||||||
if ( !!rec ) {
|
if ( !!rec ) {
|
||||||
removeFromQueue( comms, xwe, channelNo, lastMsgRcd );
|
removeFromQueue( comms, xwe, channelNo, lastMsgRcd );
|
||||||
|
|
||||||
augmentChannelAddr( rec, addr, senderID );
|
augmentChannelAddr( comms, rec, addr, senderID );
|
||||||
|
|
||||||
if ( msgID == rec->lastMsgRcd + 1 ) {
|
if ( msgID == rec->lastMsgRcd + 1 ) {
|
||||||
XP_LOGF( TAGFMT() "expected %d AND got %d", TAGPRMS,
|
XP_LOGF( TAGFMT() "expected %d AND got %d", TAGPRMS,
|
||||||
|
@ -2924,20 +2925,31 @@ logAddrs( const CommsCtxt* comms, XWEnv xwe, const char* caller )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
augmentChannelAddr( AddressRecord* const rec, const CommsAddrRec* addr,
|
augmentChannelAddr( CommsCtxt* comms, AddressRecord* const rec,
|
||||||
XWHostID hostID )
|
const CommsAddrRec* addr, XWHostID hostID )
|
||||||
{
|
{
|
||||||
augmentAddr( &rec->addr, addr );
|
augmentAddr( comms, &rec->addr, addr );
|
||||||
if ( addr_hasType( &rec->addr, COMMS_CONN_RELAY ) ) {
|
if ( addr_hasType( &rec->addr, COMMS_CONN_RELAY ) ) {
|
||||||
if ( 0 != hostID ) {
|
if ( 0 != hostID ) {
|
||||||
rec->rr.hostID = hostID;
|
rec->rr.hostID = hostID;
|
||||||
XP_LOGF( "%s: set hostID for rec %p to %d", __func__, rec, hostID );
|
XP_LOGF( "%s: set hostID for rec %p to %d", __func__, rec, hostID );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
CommsConnType typ;
|
||||||
|
for ( XP_U32 st = 0; addr_iter( addr, &typ, &st ); ) {
|
||||||
|
if ( !addr_hasType( &comms->addr, typ ) ) {
|
||||||
|
XP_LOGFF( "main addr missing type %s", ConnType2Str(typ) );
|
||||||
|
XP_ASSERT(0); /* firing */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
augmentAddr( CommsAddrRec* destAddr, const CommsAddrRec* srcAddr )
|
augmentAddr( CommsCtxt* comms, CommsAddrRec* destAddr,
|
||||||
|
const CommsAddrRec* srcAddr )
|
||||||
{
|
{
|
||||||
if ( !!srcAddr ) {
|
if ( !!srcAddr ) {
|
||||||
CommsConnType typ;
|
CommsConnType typ;
|
||||||
|
@ -2945,6 +2957,15 @@ augmentAddr( CommsAddrRec* destAddr, const CommsAddrRec* srcAddr )
|
||||||
if ( ! addr_hasType( destAddr, typ ) ) {
|
if ( ! addr_hasType( destAddr, typ ) ) {
|
||||||
XP_LOGFF( "adding new type %s to rec", ConnType2Str(typ) );
|
XP_LOGFF( "adding new type %s to rec", ConnType2Str(typ) );
|
||||||
addr_addType( destAddr, typ );
|
addr_addType( destAddr, typ );
|
||||||
|
|
||||||
|
/* If an address is getting added to a channel, the top-level
|
||||||
|
address should also include the type. The specifics of the
|
||||||
|
address don't make sense to copy, however. */
|
||||||
|
if ( ! addr_hasType( &comms->addr, typ ) ) {
|
||||||
|
XP_ASSERT( destAddr != &comms->addr ); /* we just added it, so can't be comms->addr */
|
||||||
|
XP_LOGFF( "adding %s to comms->addr", ConnType2Str(typ) );
|
||||||
|
addr_addType( &comms->addr, typ );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* src = NULL;
|
const void* src = NULL;
|
||||||
|
|
|
@ -37,14 +37,14 @@ typedef XP_U8 XWHostID;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
COMMS_CONN_NONE /* I want errors on uninited case */
|
COMMS_CONN_NONE /* I want errors on uninited case */
|
||||||
,COMMS_CONN_IR
|
,COMMS_CONN_IR /* 1 */
|
||||||
,COMMS_CONN_IP_DIRECT
|
,COMMS_CONN_IP_DIRECT /* 2 */
|
||||||
,COMMS_CONN_RELAY
|
,COMMS_CONN_RELAY /* 3 */
|
||||||
,COMMS_CONN_BT
|
,COMMS_CONN_BT /* 4 */
|
||||||
,COMMS_CONN_SMS
|
,COMMS_CONN_SMS /* 5 */
|
||||||
,COMMS_CONN_P2P /* a.k.a. Wifi direct */
|
,COMMS_CONN_P2P /* a.k.a. Wifi direct */
|
||||||
,COMMS_CONN_NFC
|
,COMMS_CONN_NFC /* 7 */
|
||||||
,COMMS_CONN_MQTT
|
,COMMS_CONN_MQTT /* 8 */
|
||||||
|
|
||||||
,COMMS_CONN_NTYPES
|
,COMMS_CONN_NTYPES
|
||||||
} CommsConnType;
|
} CommsConnType;
|
||||||
|
|
|
@ -2947,11 +2947,9 @@ main( int argc, char** argv )
|
||||||
addr_addType( &mainParams.addr, COMMS_CONN_MQTT );
|
addr_addType( &mainParams.addr, COMMS_CONN_MQTT );
|
||||||
break;
|
break;
|
||||||
case CMD_MQTTHOST:
|
case CMD_MQTTHOST:
|
||||||
addr_addType( &mainParams.addr, COMMS_CONN_MQTT );
|
|
||||||
mainParams.connInfo.mqtt.hostName = optarg;
|
mainParams.connInfo.mqtt.hostName = optarg;
|
||||||
break;
|
break;
|
||||||
case CMD_MQTTPORT:
|
case CMD_MQTTPORT:
|
||||||
addr_addType( &mainParams.addr, COMMS_CONN_MQTT );
|
|
||||||
mainParams.connInfo.mqtt.port = atoi(optarg);
|
mainParams.connInfo.mqtt.port = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case CMD_INVITEE_MQTTDEVID:
|
case CMD_INVITEE_MQTTDEVID:
|
||||||
|
|
|
@ -472,8 +472,10 @@ def build_cmds(args):
|
||||||
PARAMS += [ '--invitee-sms-number', makeSMSPhoneNo(GAME, dev) ]
|
PARAMS += [ '--invitee-sms-number', makeSMSPhoneNo(GAME, dev) ]
|
||||||
|
|
||||||
PARAMS += [ '--mqtt-port', args.MQTT_PORT, '--mqtt-host', args.MQTT_HOST ]
|
PARAMS += [ '--mqtt-port', args.MQTT_PORT, '--mqtt-host', args.MQTT_HOST ]
|
||||||
if args.ADD_MQTT and DEV == 1:
|
if args.ADD_MQTT:
|
||||||
PARAMS += [ '--force-invite' ]
|
PARAMS += [ '--with-mqtt' ]
|
||||||
|
if DEV == 1:
|
||||||
|
PARAMS += [ '--force-invite' ]
|
||||||
|
|
||||||
if args.UNDO_PCT > 0:
|
if args.UNDO_PCT > 0:
|
||||||
PARAMS += ['--undo-pct', args.UNDO_PCT]
|
PARAMS += ['--undo-pct', args.UNDO_PCT]
|
||||||
|
@ -648,6 +650,7 @@ def run_cmds(args, devs):
|
||||||
devs.remove(dev)
|
devs.remove(dev)
|
||||||
else:
|
else:
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
|
print('.', end='', flush=True)
|
||||||
|
|
||||||
# if we get here via a break, kill any remaining games
|
# if we get here via a break, kill any remaining games
|
||||||
if devs:
|
if devs:
|
||||||
|
|
Loading…
Add table
Reference in a new issue