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 27a4504f8..bde699a58 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 @@ -424,7 +424,7 @@ public class CommsTransport implements TransportProcs, switch ( conType ) { case COMMS_CONN_RELAY: Assert.assertTrue( BuildConfig.UDP_ENABLED ); - nSent = RelayService.sendPacket( context, rowID, buf ); + nSent = RelayService.sendPacket( context, rowID, buf, msgID ); break; case COMMS_CONN_SMS: nSent = NBSProto.sendPacket( context, addr.sms_phone, 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 113bcfecc..b078dae3b 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 @@ -56,10 +56,10 @@ public class MultiMsgSink implements TransportProcs { // These will be overridden by e.g. BTService which for sendViaBluetooth() // can just insert a message into its queue - public int sendViaRelay( byte[] buf, int gameID ) + public int sendViaRelay( byte[] buf, String msgID, int gameID ) { Assert.assertTrue( BuildConfig.UDP_ENABLED ); - return RelayService.sendPacket( m_context, getRowID(), buf ); + return RelayService.sendPacket( m_context, getRowID(), buf, msgID ); } public int sendViaBluetooth( byte[] buf, String msgID, int gameID, @@ -95,7 +95,7 @@ public class MultiMsgSink implements TransportProcs { int nSent = -1; switch ( typ ) { case COMMS_CONN_RELAY: - nSent = sendViaRelay( buf, gameID ); + nSent = sendViaRelay( buf, msgID, gameID ); break; case COMMS_CONN_BT: nSent = sendViaBluetooth( buf, msgID, gameID, addr ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java index 7de48cf56..554fbc048 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/RelayService.java @@ -257,9 +257,10 @@ public class RelayService extends XWJIService enqueueWork( context, intent ); } - public static int sendPacket( Context context, long rowid, byte[] msg ) + public static int sendPacket( Context context, long rowid, byte[] msg, + String msgID ) { - Log.d( TAG, "sendPacket(len=%d)", msg.length ); + Log.d( TAG, "sendPacket(len=%d, msgID=%s)", msg.length, msgID ); int result = -1; if ( NetStateCache.netAvail( context ) ) { Intent intent = getIntentTo( context, MsgCmds.SEND ) @@ -1313,12 +1314,12 @@ public class RelayService extends XWJIService DatagramSocket udpSocket = s_UDPSocket; if ( null == udpSocket ) { udpSocket = getService().connectSocketOnce(); // block until this is done + Assert.assertTrue( null != udpSocket || !BuildConfig.DEBUG ); } byte[] buf = new byte[1024]; - DatagramPacket packet = - new DatagramPacket( buf, buf.length ); - for ( ; ; ) { + DatagramPacket packet = new DatagramPacket( buf, buf.length ); + while ( null != udpSocket ) { if ( interrupted() ) { Log.d( TAG, "%s.run() interrupted; outta here", this ); break; @@ -1472,10 +1473,10 @@ public class RelayService extends XWJIService } @Override - public int sendViaRelay( byte[] buf, int gameID ) + public int sendViaRelay( byte[] buf, String msgID, int gameID ) { Assert.assertTrue( -1 != getRowID() ); - sendPacket( RelayService.this, getRowID(), buf ); + sendPacket( RelayService.this, getRowID(), buf, msgID ); return buf.length; }