mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
use ifdefs to go back to using only old-style per-device topics
This commit is contained in:
parent
cf2d49e249
commit
096c13614a
3 changed files with 17 additions and 1 deletions
|
@ -583,6 +583,14 @@ public class MQTTUtils extends Thread
|
||||||
MQTTUtils instance = getOrStart( context );
|
MQTTUtils instance = getOrStart( context );
|
||||||
if ( null != instance ) {
|
if ( null != instance ) {
|
||||||
String[] topics = XwJNI.dvc_getMQTTPubTopics( addressee, gameID );
|
String[] topics = XwJNI.dvc_getMQTTPubTopics( addressee, gameID );
|
||||||
|
if ( BuildConfig.NON_RELEASE ) {
|
||||||
|
for ( String topic : topics ) {
|
||||||
|
if ( !topic.startsWith("xw4/device/") ) {
|
||||||
|
Log.d( TAG, "bad topic: %s", topic );
|
||||||
|
Assert.failDbg();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
instance.enqueue( topics, packet );
|
instance.enqueue( topics, packet );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,9 +209,11 @@ dvc_getMQTTSubTopics( XW_DUtilCtxt* dutil, XWEnv xwe,
|
||||||
formatMQTTDevTopic( &devid, buf, VSIZE(buf) );
|
formatMQTTDevTopic( &devid, buf, VSIZE(buf) );
|
||||||
topics[count++] = appendToStorage( storage, &offset, buf );
|
topics[count++] = appendToStorage( storage, &offset, buf );
|
||||||
|
|
||||||
|
#ifdef MQTT_GAMEID_TOPICS
|
||||||
/* Then the pattern that includes gameIDs */
|
/* Then the pattern that includes gameIDs */
|
||||||
XP_SNPRINTF( buf, VSIZE(buf), "%s/+", topics[0] );
|
XP_SNPRINTF( buf, VSIZE(buf), "%s/+", topics[0] );
|
||||||
topics[count++] = appendToStorage( storage, &offset, buf );
|
topics[count++] = appendToStorage( storage, &offset, buf );
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Finally, the control pattern */
|
/* Finally, the control pattern */
|
||||||
formatMQTTCtrlTopic( &devid, buf, VSIZE(buf) );
|
formatMQTTCtrlTopic( &devid, buf, VSIZE(buf) );
|
||||||
|
@ -242,7 +244,6 @@ dvc_getMQTTPubTopics( XW_DUtilCtxt* dutil, XWEnv xwe,
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
XP_UCHAR buf[128];
|
|
||||||
|
|
||||||
XP_UCHAR devTopic[64]; /* used by two below */
|
XP_UCHAR devTopic[64]; /* used by two below */
|
||||||
formatMQTTDevTopic( devid, devTopic, VSIZE(devTopic) );
|
formatMQTTDevTopic( devid, devTopic, VSIZE(devTopic) );
|
||||||
|
@ -250,9 +251,14 @@ dvc_getMQTTPubTopics( XW_DUtilCtxt* dutil, XWEnv xwe,
|
||||||
/* device topic; eventually goes away; but invites? */
|
/* device topic; eventually goes away; but invites? */
|
||||||
topics[count++] = appendToStorage( storage, &offset, devTopic );
|
topics[count++] = appendToStorage( storage, &offset, devTopic );
|
||||||
|
|
||||||
|
#ifdef MQTT_GAMEID_TOPICS
|
||||||
|
XP_UCHAR buf[128];
|
||||||
/* gameid topic */
|
/* gameid topic */
|
||||||
XP_SNPRINTF( buf, VSIZE(buf), "%s/%X", devTopic, gameID );
|
XP_SNPRINTF( buf, VSIZE(buf), "%s/%X", devTopic, gameID );
|
||||||
topics[count++] = appendToStorage( storage, &offset, buf );
|
topics[count++] = appendToStorage( storage, &offset, buf );
|
||||||
|
#else
|
||||||
|
XP_USE(gameID);
|
||||||
|
#endif
|
||||||
|
|
||||||
XP_ASSERT( offset < storageLen );
|
XP_ASSERT( offset < storageLen );
|
||||||
XP_ASSERT( count <= *nTopics );
|
XP_ASSERT( count <= *nTopics );
|
||||||
|
|
|
@ -167,6 +167,8 @@ DEFINES += -DXWFEATURE_SLOW_ROBOT -DXWFEATURE_ROBOTPHONIES
|
||||||
DEFINES += -DXWFEATURE_DEVICE
|
DEFINES += -DXWFEATURE_DEVICE
|
||||||
DEFINES += -DXWFEATURE_KNOWNPLAYERS
|
DEFINES += -DXWFEATURE_KNOWNPLAYERS
|
||||||
|
|
||||||
|
# DEFINES += -DMQTT_GAMEID_TOPICS
|
||||||
|
|
||||||
# Support device-to-device connection via UDP, e.g. using wifi on a
|
# Support device-to-device connection via UDP, e.g. using wifi on a
|
||||||
# LAN or where the host/server isn't behind a firewall.
|
# LAN or where the host/server isn't behind a firewall.
|
||||||
# DEFINES += -DXWFEATURE_IP_DIRECT
|
# DEFINES += -DXWFEATURE_IP_DIRECT
|
||||||
|
|
Loading…
Reference in a new issue