mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
each message gets a localID so logs can show progress
And rewrite toString()
This commit is contained in:
parent
156c05d54c
commit
183b221a2e
1 changed files with 25 additions and 9 deletions
|
@ -1161,6 +1161,7 @@ public class BTService extends XWJIService {
|
||||||
int mGameID;
|
int mGameID;
|
||||||
long mStamp;
|
long mStamp;
|
||||||
byte[] mData;
|
byte[] mData;
|
||||||
|
int mLocalID;
|
||||||
|
|
||||||
MsgElem( BTCmd cmd, int gameID, String msgID, OutputPair op )
|
MsgElem( BTCmd cmd, int gameID, String msgID, OutputPair op )
|
||||||
{
|
{
|
||||||
|
@ -1185,6 +1186,8 @@ public class BTService extends XWJIService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setLocalID( int id ) { mLocalID = id; }
|
||||||
|
|
||||||
boolean isSameAs( MsgElem other )
|
boolean isSameAs( MsgElem other )
|
||||||
{
|
{
|
||||||
boolean result = mCmd == other.mCmd
|
boolean result = mCmd == other.mCmd
|
||||||
|
@ -1214,6 +1217,7 @@ public class BTService extends XWJIService {
|
||||||
private long mLastFailTime;
|
private long mLastFailTime;
|
||||||
private int mFailCount;
|
private int mFailCount;
|
||||||
private int mLength;
|
private int mLength;
|
||||||
|
private int mCounter;
|
||||||
|
|
||||||
PacketAccumulator( String addr ) {
|
PacketAccumulator( String addr ) {
|
||||||
mAddr = addr;
|
mAddr = addr;
|
||||||
|
@ -1260,17 +1264,28 @@ public class BTService extends XWJIService {
|
||||||
@Override
|
@Override
|
||||||
public synchronized String toString()
|
public synchronized String toString()
|
||||||
{
|
{
|
||||||
long age = 0;
|
StringBuilder sb = new StringBuilder("{")
|
||||||
|
.append("name: ").append( mName )
|
||||||
|
.append( ", addr: ").append( mAddr )
|
||||||
|
.append( ", failCount: " ).append( mFailCount )
|
||||||
|
.append( ", len: " ).append( mLength )
|
||||||
|
;
|
||||||
|
|
||||||
if ( 0 < mElems.size() ) {
|
if ( 0 < mElems.size() ) {
|
||||||
age = System.currentTimeMillis() - mElems.get(0).mStamp;
|
long age = System.currentTimeMillis() - mElems.get(0).mStamp;
|
||||||
|
int lowID = mElems.get(0).mLocalID;
|
||||||
|
int highID = mElems.get(mElems.size() - 1).mLocalID;
|
||||||
|
List<BTCmd> cmds = new ArrayList<>();
|
||||||
|
for ( MsgElem elem : mElems ) {
|
||||||
|
cmds.add( elem.mCmd );
|
||||||
|
}
|
||||||
|
sb.append( ", age: " ).append( age )
|
||||||
|
.append( ", ids: ").append(lowID).append('-').append(highID)
|
||||||
|
.append( ", cmds: " ).append( TextUtils.join(",", cmds) )
|
||||||
|
;
|
||||||
}
|
}
|
||||||
List<BTCmd> cmds = new ArrayList<>();
|
|
||||||
for ( MsgElem elem : mElems ) {
|
return sb.append('}').toString();
|
||||||
cmds.add( elem.mCmd );
|
|
||||||
}
|
|
||||||
return String.format("{name: %s, addr: %s, age: %dms, failCount: %d, len: %d, cmds: %s}",
|
|
||||||
mName, mAddr, age, mFailCount, mLength,
|
|
||||||
TextUtils.join(",", cmds) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int writeAndCheck( BluetoothSocket socket, DataOutputStream dos,
|
int writeAndCheck( BluetoothSocket socket, DataOutputStream dos,
|
||||||
|
@ -1494,6 +1509,7 @@ public class BTService extends XWJIService {
|
||||||
if ( dupFound ) {
|
if ( dupFound ) {
|
||||||
Log.d( TAG, "append(): dropping dupe: %s", newElem );
|
Log.d( TAG, "append(): dropping dupe: %s", newElem );
|
||||||
} else {
|
} else {
|
||||||
|
newElem.setLocalID( mCounter++ );
|
||||||
mElems.add( newElem );
|
mElems.add( newElem );
|
||||||
mLength += newElem.size();
|
mLength += newElem.size();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue