diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java index 283e2798d..f26ecec12 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MQTTUtils.java @@ -49,6 +49,7 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba private static final String TAG = MQTTUtils.class.getSimpleName(); private static final String KEY_NEXT_REG = TAG + "/next_reg"; private static final String KEY_LAST_WRITE = TAG + "/last_write"; + private static final String KEY_TMP_KEY = TAG + "/tmp_key"; private static enum State { NONE, CONNECTING, CONNECTED, SUBSCRIBING, SUBSCRIBED, CLOSING }; @@ -314,6 +315,7 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba params.put( "myNow", now ); params.put( "loc", LocUtils.getCurLocale( mContext ) ); params.put( "knowsDup", true ); + params.put( "tmpKey", getTmpKey(mContext) ); String fcmid = FBMService.getFCMDevID( mContext ); if ( null != fcmid ) { @@ -356,6 +358,19 @@ public class MQTTUtils extends Thread implements IMqttActionListener, MqttCallba } } + private static int sTmpKey; + private static int getTmpKey( Context context ) + { + while ( 0 == sTmpKey ) { + sTmpKey = DBUtils.getIntFor( context, KEY_TMP_KEY, 0 ); + if ( 0 == sTmpKey ) { + sTmpKey = Math.abs( Utils.nextRandomInt() ); + DBUtils.setIntFor( context, KEY_TMP_KEY, sTmpKey ); + } + } + return sTmpKey; + } + private void disconnect() { Log.d( TAG, "%H.disconnect()", this );