log msgIDs (relay only for now)

I want to track and eliminate the duplication of the 0th message.
This commit is contained in:
Eric House 2019-04-09 08:59:57 -07:00
parent 22a68dd8cf
commit 8044593249
3 changed files with 12 additions and 11 deletions

View file

@ -424,7 +424,7 @@ public class CommsTransport implements TransportProcs,
switch ( conType ) { switch ( conType ) {
case COMMS_CONN_RELAY: case COMMS_CONN_RELAY:
Assert.assertTrue( BuildConfig.UDP_ENABLED ); Assert.assertTrue( BuildConfig.UDP_ENABLED );
nSent = RelayService.sendPacket( context, rowID, buf ); nSent = RelayService.sendPacket( context, rowID, buf, msgID );
break; break;
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
nSent = NBSProto.sendPacket( context, addr.sms_phone, nSent = NBSProto.sendPacket( context, addr.sms_phone,

View file

@ -56,10 +56,10 @@ public class MultiMsgSink implements TransportProcs {
// These will be overridden by e.g. BTService which for sendViaBluetooth() // These will be overridden by e.g. BTService which for sendViaBluetooth()
// can just insert a message into its queue // 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 ); 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, public int sendViaBluetooth( byte[] buf, String msgID, int gameID,
@ -95,7 +95,7 @@ public class MultiMsgSink implements TransportProcs {
int nSent = -1; int nSent = -1;
switch ( typ ) { switch ( typ ) {
case COMMS_CONN_RELAY: case COMMS_CONN_RELAY:
nSent = sendViaRelay( buf, gameID ); nSent = sendViaRelay( buf, msgID, gameID );
break; break;
case COMMS_CONN_BT: case COMMS_CONN_BT:
nSent = sendViaBluetooth( buf, msgID, gameID, addr ); nSent = sendViaBluetooth( buf, msgID, gameID, addr );

View file

@ -257,9 +257,10 @@ public class RelayService extends XWJIService
enqueueWork( context, intent ); 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; int result = -1;
if ( NetStateCache.netAvail( context ) ) { if ( NetStateCache.netAvail( context ) ) {
Intent intent = getIntentTo( context, MsgCmds.SEND ) Intent intent = getIntentTo( context, MsgCmds.SEND )
@ -1313,12 +1314,12 @@ public class RelayService extends XWJIService
DatagramSocket udpSocket = s_UDPSocket; DatagramSocket udpSocket = s_UDPSocket;
if ( null == udpSocket ) { if ( null == udpSocket ) {
udpSocket = getService().connectSocketOnce(); // block until this is done udpSocket = getService().connectSocketOnce(); // block until this is done
Assert.assertTrue( null != udpSocket || !BuildConfig.DEBUG );
} }
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];
DatagramPacket packet = DatagramPacket packet = new DatagramPacket( buf, buf.length );
new DatagramPacket( buf, buf.length ); while ( null != udpSocket ) {
for ( ; ; ) {
if ( interrupted() ) { if ( interrupted() ) {
Log.d( TAG, "%s.run() interrupted; outta here", this ); Log.d( TAG, "%s.run() interrupted; outta here", this );
break; break;
@ -1472,10 +1473,10 @@ public class RelayService extends XWJIService
} }
@Override @Override
public int sendViaRelay( byte[] buf, int gameID ) public int sendViaRelay( byte[] buf, String msgID, int gameID )
{ {
Assert.assertTrue( -1 != getRowID() ); Assert.assertTrue( -1 != getRowID() );
sendPacket( RelayService.this, getRowID(), buf ); sendPacket( RelayService.this, getRowID(), buf, msgID );
return buf.length; return buf.length;
} }