diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTConnection.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTConnection.java index 937c1d95c..8e1ddeca2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTConnection.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BTConnection.java @@ -223,8 +223,9 @@ public class BTConnection extends BroadcastReceiver { } // - public static void enqueueFor( byte[] buf ) + public static void enqueueFor( byte[] buf, String target ) { + DbgUtils.logf( "got %d bytes for %s", buf.length, target ); } private static class InviteThread extends Thread { @@ -357,7 +358,8 @@ public class BTConnection extends BroadcastReceiver { int gameID = is.readInt(); DbgUtils.logf( "receiveInvitation: got gameID of %d", gameID ); - GameUtils.makeNewBTGame( context, gameID ); + BluetoothDevice host = socket.getRemoteDevice(); + GameUtils.makeNewBTGame( context, gameID, host.getName() ); // Post notification that, when selected, will create a game // -- or ask if user wants to create one. diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java index 1e538cdc1..893106e33 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java @@ -38,6 +38,7 @@ import android.os.Message; import org.eehouse.android.xw4.jni.*; import org.eehouse.android.xw4.jni.JNIThread.*; import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole; +import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType; public class CommsTransport implements TransportProcs, NetStateCache.StateChangedIf { @@ -387,6 +388,8 @@ public class CommsTransport implements TransportProcs, // } break; case COMMS_CONN_BT: + BTConnection.enqueueFor( buf, m_addr.bt_hostName ); + break; default: Assert.fail(); break; @@ -397,7 +400,7 @@ public class CommsTransport implements TransportProcs, // resend does. DbgUtils.logf( "transportSend(%d)=>%d", buf.length, nSent ); return nSent; - } + } public void relayStatus( CommsRelayState newState ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index 6d9a42b29..636263f35 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -383,7 +383,8 @@ public class GameUtils { private static long makeNewMultiGame( Context context, CommsAddrRec addr, int[] lang, int nPlayersT, int nPlayersH, - String inviteID, int gameID ) + String inviteID, int gameID, + boolean isHost, String btHost ) { long rowid = -1; @@ -395,6 +396,11 @@ public class GameUtils { if ( 0 != gameID ) { gi.gameID = gameID; } + if ( isHost ) { + gi.serverRole = DeviceRole.SERVER_ISSERVER; + } else if ( null != btHost ) { + addr.bt_hostName = btHost; + } // Will need to add a setNPlayers() method to gi to make this // work Assert.assertTrue( gi.nPlayers == nPlayersT ); @@ -418,7 +424,7 @@ public class GameUtils { addr.ip_relay_invite = room; return makeNewMultiGame( context, addr, lang, nPlayersT, - nPlayersH, inviteID, 0 ); + nPlayersH, inviteID, 0, false, null ); } public static long makeNewNetGame( Context context, String room, @@ -434,7 +440,8 @@ public class GameUtils { info.nPlayers ); } - public static long makeNewBTGame( Context context, int gameID ) + public static long makeNewBTGame( Context context, int gameID, + String hostName ) { long rowid = -1; CommsAddrRec addr = @@ -442,7 +449,8 @@ public class GameUtils { CommsAddrRec.CommsConnType.COMMS_CONN_BT ); int[] lang = { 1 }; // English - return makeNewMultiGame( context, addr, lang, 2, 1, null, gameID ); + return makeNewMultiGame( context, addr, lang, 2, 1, + null, gameID, null == hostName, hostName ); } public static void launchInviteActivity( Context context, diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java index c0124b8cc..9d07c8b04 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NewGameActivity.java @@ -284,7 +284,7 @@ public class NewGameActivity extends XWActivity switch( msg.what ) { case BTConnection.CONNECT_ACCEPTED: GameUtils.makeNewBTGame( NewGameActivity.this, - msg.arg1 ); + msg.arg1, null ); finish(); break; case BTConnection.CONNECT_REFUSED: