From 14edbd7f18c00013bff6879084c8244f2cdaedf0 Mon Sep 17 00:00:00 2001 From: Andy2 <andy2@trand.private.network> Date: Fri, 24 Sep 2010 18:49:34 -0700 Subject: [PATCH] implement setIsServer(). With this change I've been successful -- once -- having two games on the same device play against each other. --- .../org/eehouse/android/xw4/BoardActivity.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index eadca9ba6..cb729bf89 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -604,6 +604,21 @@ public class BoardActivity extends Activity implements UtilCtxt { R.string.tiles_left_title ); } + public void setIsServer( boolean isServer ) + { + Utils.logf( "setIsServer(%s)", isServer?"true":"false" ); + DeviceRole newRole = isServer? DeviceRole.SERVER_ISSERVER + : DeviceRole.SERVER_ISCLIENT; + if ( newRole != m_gi.serverRole ) { + Utils.logf( "new role: %s; old role: %s", + newRole.toString(), m_gi.serverRole.toString() ); + m_gi.serverRole = newRole; + if ( !isServer ) { + m_jniThread.handle( JNIThread.JNICmd.CMD_SWITCHCLIENT ); + } + } + } + public void setTimer( int why, int when, int handle ) { if ( null != m_timers[why] ) {