diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/CommsTransport.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/CommsTransport.java index 865ed895a..fd995b4fd 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/CommsTransport.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/CommsTransport.java @@ -126,7 +126,7 @@ public class CommsTransport implements TransportProcs { nSent = NFCUtils.addMsgFor( buf, gameID ); break; case COMMS_CONN_MQTT: - nSent = MQTTUtils.send( context, addr.mqtt_devID, gameID, timestamp, buf ); + nSent = MQTTUtils.send( context, addr.mqtt_devID, gameID, buf ); break; default: Assert.failDbg(); 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 878dce265..bb8971038 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 @@ -543,12 +543,12 @@ public class MQTTUtils extends Thread } public static void sendInvite( Context context, String invitee, - int timestamp, NetLaunchInfo nli ) + NetLaunchInfo nli ) { Log.d( TAG, "sendInvite(invitee: %s, nli: %s)", invitee, nli ); byte[][][] packets = {null}; String[][] topics = {null}; - XwJNI.dvc_makeMQTTInvites( invitee, timestamp, nli, topics, packets ); + XwJNI.dvc_makeMQTTInvites( invitee, nli, topics, packets ); addToSendQueue( context, topics[0], packets[0] ); } @@ -570,13 +570,13 @@ public class MQTTUtils extends Thread } public static int send( Context context, String addressee, int gameID, - int timestamp, byte[] buf ) + byte[] buf ) { Log.d( TAG, "send(to:%s, len: %d)", addressee, buf.length ); Assert.assertTrueNR( 16 == addressee.length() ); String[][] topics = {null}; byte[][][] packets = {null}; - XwJNI.dvc_makeMQTTMessages( addressee, gameID, timestamp, buf, topics, packets ); + XwJNI.dvc_makeMQTTMessages( addressee, gameID, buf, topics, packets ); addToSendQueue( context, topics[0], packets[0] ); return buf.length; } diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiMsgSink.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiMsgSink.java index b4f67719f..511eb0b4f 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiMsgSink.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/MultiMsgSink.java @@ -81,9 +81,9 @@ public class MultiMsgSink implements TransportProcs { return NFCUtils.addMsgFor( buf, gameID ); } - int sendViaMQTT( String addressee, byte[] buf, int gameID, int timestamp ) + int sendViaMQTT( String addressee, byte[] buf, int gameID ) { - return MQTTUtils.send( m_context, addressee, gameID, timestamp, buf ); + return MQTTUtils.send( m_context, addressee, gameID, buf ); } public int numSent() @@ -124,7 +124,7 @@ public class MultiMsgSink implements TransportProcs { nSent = sendViaNFC( buf, gameID ); break; case COMMS_CONN_MQTT: - nSent = sendViaMQTT( addr.mqtt_devID, buf, gameID, timestamp ); + nSent = sendViaMQTT( addr.mqtt_devID, buf, gameID ); break; default: Assert.failDbg(); @@ -161,7 +161,7 @@ public class MultiMsgSink implements TransportProcs { case COMMS_CONN_MQTT: target = addr.mqtt_devID; means = InviteMeans.MQTT; - MQTTUtils.sendInvite( context, addr.mqtt_devID, timestamp, nli ); + MQTTUtils.sendInvite( context, addr.mqtt_devID, nli ); success = true; break; case COMMS_CONN_SMS: diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java index 3535ad510..f97fe9eea 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/jni/XwJNI.java @@ -153,20 +153,18 @@ public class XwJNI { return dvc_getMQTTSubTopics( getJNI().m_ptrGlobals ); } - public static void dvc_makeMQTTInvites( String invitee, int timestamp, - NetLaunchInfo nli, String[][] topics, - byte[][][] packets ) + public static void dvc_makeMQTTInvites( String invitee, NetLaunchInfo nli, + String[][] topics, byte[][][] packets ) { - dvc_makeMQTTInvites( getJNI().m_ptrGlobals, invitee, timestamp, + dvc_makeMQTTInvites( getJNI().m_ptrGlobals, invitee, nli, topics, packets ); } - public static void dvc_makeMQTTMessages( String addressee, int gameID, - int timestamp, byte[] buf, + public static void dvc_makeMQTTMessages( String addressee, int gameID, byte[] buf, String[][] topics, byte[][][] packets ) { dvc_makeMQTTMessages( getJNI().m_ptrGlobals, addressee, gameID, - timestamp, buf, topics, packets ); + buf, topics, packets ); } public static void dvc_makeMQTTNoSuchGames( String addressee, int gameID, @@ -772,14 +770,12 @@ public class XwJNI { private static native String[] dvc_getMQTTSubTopics( long jniState ); private static native void dvc_makeMQTTInvites( long jniState, String invitee, - int timestamp, NetLaunchInfo nli, String[][] topics, byte[][][] packets ); private static native void dvc_makeMQTTMessages( long jniState, String addressee, - int gameID, - int timestamp, byte[] buf, + int gameID, byte[] buf, String[][] topics, byte[][][] packets ); diff --git a/xwords4/android/jni/Android.mk b/xwords4/android/jni/Android.mk index 7f921084f..781815171 100644 --- a/xwords4/android/jni/Android.mk +++ b/xwords4/android/jni/Android.mk @@ -51,8 +51,6 @@ LOCAL_DEFINES += \ -DMQTT_DEV_TOPICS \ -DMQTT_GAMEID_TOPICS \ -# -DMQTT_USE_PROTO=2 \ - # XWFEATURE_RAISETILE: first, fix to not use timer # -DXWFEATURE_RAISETILE \ diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index d9927315a..f58ff9de3 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -737,7 +737,7 @@ wrapResults( jobjectArray jTopicsOut, jobjectArray jPacketsOut, MTPData* mtp ) JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1makeMQTTInvites ( JNIEnv* env, jclass C, jlong jniGlobalPtr, jstring jAddressee, - jint jTimestamp, jobject jnli, jobjectArray jTopicsOut, + jobject jnli, jobjectArray jTopicsOut, jobjectArray jPacketsOut ) { DVC_HEADER(jniGlobalPtr); @@ -752,7 +752,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1makeMQTTInvites jstrToDevID( env, jAddressee, &addressee ); dvc_makeMQTTInvites( globalState->dutil, env, msgAndTopicProc, &mtp, - &addressee, &nli, jTimestamp ); + &addressee, &nli ); wrapResults( jTopicsOut, jPacketsOut, &mtp ); DVC_HEADER_END(); @@ -761,7 +761,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1makeMQTTInvites JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1makeMQTTMessages ( JNIEnv* env, jclass C, jlong jniGlobalPtr, jstring jAddressee, - jint jGameID, jint jTimestamp, jbyteArray jmsg, + jint jGameID, jbyteArray jmsg, jobjectArray jTopicsOut, jobjectArray jPacketsOut ) { LOG_FUNC(); @@ -778,8 +778,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1makeMQTTMessages XP_U16 len = (*env)->GetArrayLength( env, jmsg ); jbyte* buf = (*env)->GetByteArrayElements( env, jmsg, NULL ); dvc_makeMQTTMessages( globalState->dutil, env, msgAndTopicProc, &mtp, - &addressee, jGameID, jTimestamp, - (const XP_U8*)buf, len ); + &addressee, jGameID, (const XP_U8*)buf, len ); (*env)->ReleaseByteArrayElements( env, jmsg, buf, 0 ); wrapResults( jTopicsOut, jPacketsOut, &mtp ); @@ -800,7 +799,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_dvc_1makeMQTTNoSuchGames jstrToDevID( env, jAddressee, &addressee ); dvc_makeMQTTNoSuchGames( globalState->dutil, env, msgAndTopicProc, &mtp, - &addressee, jgameid, 0 ); + &addressee, jgameid ); wrapResults( jTopicsOut, jPacketsOut, &mtp ); diff --git a/xwords4/common/device.c b/xwords4/common/device.c index 73260b3ff..460c7120c 100644 --- a/xwords4/common/device.c +++ b/xwords4/common/device.c @@ -241,15 +241,15 @@ typedef enum { CMD_INVITE, CMD_MSG, CMD_DEVGONE, } MQTTCmd; // #define PROTO_0 0 #define PROTO_1 1 /* moves gameID into "header" relay2 knows about */ -#define PROTO_2 2 /* adds timestamp to header */ -#define PROTO_3 3 /* adds multi-message, removes gameID */ +#define _PROTO_2 2 /* never used, and now deprecated (value 2 is) */ +#define PROTO_3 3 /* adds multi-message, removes gameID and timestamp */ #ifndef MQTT_USE_PROTO # define MQTT_USE_PROTO PROTO_1 #endif static void addHeaderGameIDAndCmd( XW_DUtilCtxt* dutil, XWEnv xwe, MQTTCmd cmd, - XP_U32 gameID, XP_U32 timestamp, XWStreamCtxt* stream ) + XP_U32 gameID, XWStreamCtxt* stream ) { stream_putU8( stream, MQTT_USE_PROTO ); @@ -259,10 +259,6 @@ addHeaderGameIDAndCmd( XW_DUtilCtxt* dutil, XWEnv xwe, MQTTCmd cmd, stream_putBytes( stream, &myID, sizeof(myID) ); stream_putU32( stream, gameID ); - if ( PROTO_2 <= MQTT_USE_PROTO ) { - XP_ASSERT(0 != timestamp); - stream_putU32( stream, timestamp ); - } stream_putU8( stream, cmd ); } @@ -270,9 +266,8 @@ addHeaderGameIDAndCmd( XW_DUtilCtxt* dutil, XWEnv xwe, MQTTCmd cmd, #ifdef MQTT_GAMEID_TOPICS static void addProto3HeaderCmd( XW_DUtilCtxt* dutil, XWEnv xwe, MQTTCmd cmd, - XP_U32 timestamp, XWStreamCtxt* stream ) + XWStreamCtxt* stream ) { - XP_ASSERT( 0 != timestamp ); stream_putU8( stream, PROTO_3 ); MQTTDevID myID; @@ -280,8 +275,6 @@ addProto3HeaderCmd( XW_DUtilCtxt* dutil, XWEnv xwe, MQTTCmd cmd, myID = htobe64( myID ); stream_putBytes( stream, &myID, sizeof(myID) ); - stream_putU32( stream, timestamp ); - stream_putU8( stream, cmd ); } #endif @@ -296,15 +289,13 @@ void dvc_makeMQTTInvites( XW_DUtilCtxt* dutil, XWEnv xwe, MsgAndTopicProc proc, void* closure, const MQTTDevID* addressee, - const NetLaunchInfo* nli, - XP_U32 timestamp ) + const NetLaunchInfo* nli ) { XP_UCHAR devTopic[64]; /* used by two below */ formatMQTTDevTopic( addressee, devTopic, VSIZE(devTopic) ); /* Stream format is identical for both topics */ XWStreamCtxt* stream = mkStream( dutil ); - addHeaderGameIDAndCmd( dutil, xwe, CMD_INVITE, nli->gameID, - timestamp, stream ); + addHeaderGameIDAndCmd( dutil, xwe, CMD_INVITE, nli->gameID, stream ); nli_saveToStream( nli, stream ); #ifdef MQTT_DEV_TOPICS @@ -330,8 +321,7 @@ void dvc_makeMQTTMessages( XW_DUtilCtxt* dutil, XWEnv xwe, MsgAndTopicProc proc, void* closure, const MQTTDevID* addressee, - XP_U32 gameID, XP_U32 timestamp, - const XP_U8* buf, XP_U16 len ) + XP_U32 gameID, const XP_U8* buf, XP_U16 len ) { XP_UCHAR devTopic[64]; /* used by two below */ formatMQTTDevTopic( addressee, devTopic, VSIZE(devTopic) ); @@ -339,10 +329,7 @@ dvc_makeMQTTMessages( XW_DUtilCtxt* dutil, XWEnv xwe, #ifdef MQTT_DEV_TOPICS { XWStreamCtxt* stream = mkStream( dutil ); - addHeaderGameIDAndCmd( dutil, xwe, CMD_MSG, gameID, timestamp, stream ); - if ( PROTO_2 <= MQTT_USE_PROTO ) { - stream_putU32VL( stream, len ); - } + addHeaderGameIDAndCmd( dutil, xwe, CMD_MSG, gameID, stream ); stream_putBytes( stream, buf, len ); callProc( proc, closure, devTopic, stream ); stream_destroy( stream, xwe ); @@ -352,7 +339,7 @@ dvc_makeMQTTMessages( XW_DUtilCtxt* dutil, XWEnv xwe, #ifdef MQTT_GAMEID_TOPICS { XWStreamCtxt* stream = mkStream( dutil ); - addProto3HeaderCmd( dutil, xwe, CMD_MSG, timestamp, stream ); + addProto3HeaderCmd( dutil, xwe, CMD_MSG, stream ); /* For now, we ship one message per packet. But the receiving code should be ready */ @@ -378,19 +365,13 @@ void dvc_makeMQTTNoSuchGames( XW_DUtilCtxt* dutil, XWEnv xwe, MsgAndTopicProc proc, void* closure, const MQTTDevID* addressee, - XP_U32 gameID, XP_U32 timestamp ) + XP_U32 gameID ) { XP_UCHAR devTopic[64]; /* used by two below */ formatMQTTDevTopic( addressee, devTopic, VSIZE(devTopic) ); - if ( 0 == timestamp ) { - timestamp = dutil_getCurSeconds( dutil, xwe ); - XP_LOGFF( "replacing timestamp of 0" ); - } - XWStreamCtxt* stream = mkStream( dutil ); - addHeaderGameIDAndCmd( dutil, xwe, CMD_DEVGONE, gameID, - timestamp, stream ); + addHeaderGameIDAndCmd( dutil, xwe, CMD_DEVGONE, gameID, stream ); #ifdef MQTT_DEV_TOPICS callProc( proc, closure, devTopic, stream ); #endif @@ -474,7 +455,7 @@ dvc_parseMQTTPacket( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* topic, XP_U8 proto = 0; if ( stream_gotU8( stream, &proto ) - && (proto == PROTO_1 || proto == PROTO_2 || proto == PROTO_3 ) ) { + && (proto == PROTO_1 || proto == PROTO_3 ) ) { MQTTDevID senderID; stream_getBytes( stream, &senderID, sizeof(senderID) ); senderID = be64toh( senderID ); @@ -489,18 +470,6 @@ dvc_parseMQTTPacket( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* topic, XP_ASSERT( 0 != gameID ); } - XP_U32 timestamp = 0; - if ( PROTO_2 <= proto ) { - timestamp = stream_getU32( stream ); -#ifdef DEBUG - if ( 0 < timestamp ) { - XP_U32 now = dutil_getCurSeconds( dutil, xwe ); - XP_LOGFF( "delivery took %ds", now - timestamp ); - } -#else - XP_USE( timestamp ); -#endif - } MQTTCmd cmd = stream_getU8( stream ); /* Need to ack even if discarded/malformed */ diff --git a/xwords4/common/device.h b/xwords4/common/device.h index 7cff34378..96d169e9b 100644 --- a/xwords4/common/device.h +++ b/xwords4/common/device.h @@ -41,18 +41,16 @@ void dvc_getMQTTSubTopics( XW_DUtilCtxt* dutil, XWEnv xwe, void dvc_makeMQTTInvites( XW_DUtilCtxt* dutil, XWEnv xwe, MsgAndTopicProc proc, void* closure, const MQTTDevID* addressee, - const NetLaunchInfo* nli, - XP_U32 timestamp ); + const NetLaunchInfo* nli ); void dvc_makeMQTTMessages( XW_DUtilCtxt* dutil, XWEnv xwe, MsgAndTopicProc proc, void* closure, const MQTTDevID* addressee, - XP_U32 gameID, XP_U32 timestamp, - const XP_U8* buf, XP_U16 len ); + XP_U32 gameID, const XP_U8* buf, XP_U16 len ); void dvc_makeMQTTNoSuchGames( XW_DUtilCtxt* dutil, XWEnv xwe, MsgAndTopicProc proc, void* closure, const MQTTDevID* addressee, - XP_U32 gameID, XP_U32 timestamp ); + XP_U32 gameID ); void dvc_parseMQTTPacket( XW_DUtilCtxt* dutil, XWEnv xwe, const XP_UCHAR* topic, const XP_U8* buf, XP_U16 len ); #endif diff --git a/xwords4/linux/Makefile b/xwords4/linux/Makefile index dae97a0ed..38868c2cf 100644 --- a/xwords4/linux/Makefile +++ b/xwords4/linux/Makefile @@ -272,10 +272,6 @@ LIBS += `pkg-config --libs glib-2.0` CFLAGS += $(POINTER_SUPPORT) CFLAGS += -DDROP_BITMAPS -# Turn on for testing. Eventually, just turn on, but sends to old -# builds will then fail -# CFLAGS += -DMQTT_USE_PROTO=2 - ifneq (,$(findstring DPLATFORM_NCURSES,$(DEFINES))) LIBS += $(OE_LIBDIR) -lncursesw endif