mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
include bt name of host in client games, but not of client[s] in host
games. This allows clients to pass host name for use in addressing when their initial message is sent.
This commit is contained in:
parent
ac6ecfa845
commit
74efac3dd9
4 changed files with 21 additions and 8 deletions
|
@ -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 {
|
private static class InviteThread extends Thread {
|
||||||
|
@ -357,7 +358,8 @@ public class BTConnection extends BroadcastReceiver {
|
||||||
int gameID = is.readInt();
|
int gameID = is.readInt();
|
||||||
DbgUtils.logf( "receiveInvitation: got gameID of %d", gameID );
|
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
|
// Post notification that, when selected, will create a game
|
||||||
// -- or ask if user wants to create one.
|
// -- or ask if user wants to create one.
|
||||||
|
|
|
@ -38,6 +38,7 @@ import android.os.Message;
|
||||||
import org.eehouse.android.xw4.jni.*;
|
import org.eehouse.android.xw4.jni.*;
|
||||||
import org.eehouse.android.xw4.jni.JNIThread.*;
|
import org.eehouse.android.xw4.jni.JNIThread.*;
|
||||||
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
import org.eehouse.android.xw4.jni.CurGameInfo.DeviceRole;
|
||||||
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
|
|
||||||
public class CommsTransport implements TransportProcs,
|
public class CommsTransport implements TransportProcs,
|
||||||
NetStateCache.StateChangedIf {
|
NetStateCache.StateChangedIf {
|
||||||
|
@ -387,6 +388,8 @@ public class CommsTransport implements TransportProcs,
|
||||||
// }
|
// }
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_BT:
|
case COMMS_CONN_BT:
|
||||||
|
BTConnection.enqueueFor( buf, m_addr.bt_hostName );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
break;
|
break;
|
||||||
|
@ -397,7 +400,7 @@ public class CommsTransport implements TransportProcs,
|
||||||
// resend does.
|
// resend does.
|
||||||
DbgUtils.logf( "transportSend(%d)=>%d", buf.length, nSent );
|
DbgUtils.logf( "transportSend(%d)=>%d", buf.length, nSent );
|
||||||
return nSent;
|
return nSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void relayStatus( CommsRelayState newState )
|
public void relayStatus( CommsRelayState newState )
|
||||||
{
|
{
|
||||||
|
|
|
@ -383,7 +383,8 @@ public class GameUtils {
|
||||||
private static long makeNewMultiGame( Context context, CommsAddrRec addr,
|
private static long makeNewMultiGame( Context context, CommsAddrRec addr,
|
||||||
int[] lang,
|
int[] lang,
|
||||||
int nPlayersT, int nPlayersH,
|
int nPlayersT, int nPlayersH,
|
||||||
String inviteID, int gameID )
|
String inviteID, int gameID,
|
||||||
|
boolean isHost, String btHost )
|
||||||
{
|
{
|
||||||
long rowid = -1;
|
long rowid = -1;
|
||||||
|
|
||||||
|
@ -395,6 +396,11 @@ public class GameUtils {
|
||||||
if ( 0 != gameID ) {
|
if ( 0 != gameID ) {
|
||||||
gi.gameID = 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
|
// Will need to add a setNPlayers() method to gi to make this
|
||||||
// work
|
// work
|
||||||
Assert.assertTrue( gi.nPlayers == nPlayersT );
|
Assert.assertTrue( gi.nPlayers == nPlayersT );
|
||||||
|
@ -418,7 +424,7 @@ public class GameUtils {
|
||||||
addr.ip_relay_invite = room;
|
addr.ip_relay_invite = room;
|
||||||
|
|
||||||
return makeNewMultiGame( context, addr, lang, nPlayersT,
|
return makeNewMultiGame( context, addr, lang, nPlayersT,
|
||||||
nPlayersH, inviteID, 0 );
|
nPlayersH, inviteID, 0, false, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long makeNewNetGame( Context context, String room,
|
public static long makeNewNetGame( Context context, String room,
|
||||||
|
@ -434,7 +440,8 @@ public class GameUtils {
|
||||||
info.nPlayers );
|
info.nPlayers );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long makeNewBTGame( Context context, int gameID )
|
public static long makeNewBTGame( Context context, int gameID,
|
||||||
|
String hostName )
|
||||||
{
|
{
|
||||||
long rowid = -1;
|
long rowid = -1;
|
||||||
CommsAddrRec addr =
|
CommsAddrRec addr =
|
||||||
|
@ -442,7 +449,8 @@ public class GameUtils {
|
||||||
CommsAddrRec.CommsConnType.COMMS_CONN_BT );
|
CommsAddrRec.CommsConnType.COMMS_CONN_BT );
|
||||||
|
|
||||||
int[] lang = { 1 }; // English
|
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,
|
public static void launchInviteActivity( Context context,
|
||||||
|
|
|
@ -284,7 +284,7 @@ public class NewGameActivity extends XWActivity
|
||||||
switch( msg.what ) {
|
switch( msg.what ) {
|
||||||
case BTConnection.CONNECT_ACCEPTED:
|
case BTConnection.CONNECT_ACCEPTED:
|
||||||
GameUtils.makeNewBTGame( NewGameActivity.this,
|
GameUtils.makeNewBTGame( NewGameActivity.this,
|
||||||
msg.arg1 );
|
msg.arg1, null );
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
case BTConnection.CONNECT_REFUSED:
|
case BTConnection.CONNECT_REFUSED:
|
||||||
|
|
Loading…
Add table
Reference in a new issue