move responsibility for letting other device know a participant game

has loaded into CommsTransport.
This commit is contained in:
Eric House 2012-02-06 06:53:28 -08:00
parent d8ee493f1b
commit 39e30184b1
2 changed files with 25 additions and 8 deletions

View file

@ -1,6 +1,6 @@
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */ /* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
/* /*
* Copyright 2009-2011 by Eric House (xwords@eehouse.org). All * Copyright 2009 - 2012 by Eric House (xwords@eehouse.org). All
* rights reserved. * rights reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -1080,7 +1080,7 @@ public class BoardActivity extends XWActivity
public void playerScoreHeld( int player ) public void playerScoreHeld( int player )
{ {
String expl = XwJNI.model_getPlayersLastScore( m_jniGamePtr, String expl = XwJNI.model_getPlayersLastScore( m_jniGamePtr,
player ); player );
if ( expl.length() == 0 ) { if ( expl.length() == 0 ) {
expl = getString( R.string.no_moves_made ); expl = getString( R.string.no_moves_made );
} }
@ -1379,9 +1379,7 @@ public class BoardActivity extends XWActivity
m_jniGamePtr = XwJNI.initJNI(); m_jniGamePtr = XwJNI.initJNI();
boolean standalone = if ( m_gi.serverRole != DeviceRole.SERVER_STANDALONE ) {
m_gi.serverRole == DeviceRole.SERVER_STANDALONE;
if ( !standalone ) {
m_xport = new CommsTransport( m_jniGamePtr, this, this, m_xport = new CommsTransport( m_jniGamePtr, this, this,
m_gi.serverRole ); m_gi.serverRole );
} }
@ -1463,9 +1461,9 @@ public class BoardActivity extends XWActivity
DBUtils.setMsgFlags( m_rowid, GameSummary.MSG_FLAGS_NONE ); DBUtils.setMsgFlags( m_rowid, GameSummary.MSG_FLAGS_NONE );
} }
if ( !standalone ) { if ( null != m_xport ) {
trySendChats(); trySendChats();
m_jniThread.handle( JNIThread.JNICmd.CMD_RESEND ); m_xport.tickle();
} }
} }
} }

View file

@ -1,6 +1,6 @@
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */ /* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
/* /*
* Copyright 2009-2010 by Eric House (xwords@eehouse.org). All * Copyright 2009 - 2012 by Eric House (xwords@eehouse.org). All
* rights reserved. * rights reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -221,6 +221,25 @@ public class CommsTransport implements TransportProcs,
} }
} }
public void tickle()
{
CommsAddrRec addr = new CommsAddrRec( m_context );
XwJNI.comms_getAddr( m_jniGamePtr, addr );
switch( addr.conType ) {
case COMMS_CONN_RELAY:
// do nothing
break;
case COMMS_CONN_BT:
// Let other know I'm here
m_jniThread.handle( JNIThread.JNICmd.CMD_RESEND );
break;
default:
DbgUtils.logf( "tickle: unexpected type %s",
addr.conType.toString() );
Assert.fail();
}
}
private synchronized void putOut( final byte[] buf ) private synchronized void putOut( final byte[] buf )
{ {
int len = buf.length; int len = buf.length;