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 ) {
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,

View file

@ -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 );

View file

@ -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;
}