diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index d98c53d88..b1170d854 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -979,6 +979,16 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1resendAll XWJNI_END(); } +JNIEXPORT void JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_comms_1transportFailed +( JNIEnv* env, jclass C, jint gamePtr ) +{ + XWJNI_START(); + XP_ASSERT( !!state->game.comms ); + (void)comms_transportFailed( state->game.comms ); + XWJNI_END(); +} + JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_server_1endGame ( JNIEnv* env, jclass C, jint gamePtr ) 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 784a5c94b..68107a1aa 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/CommsTransport.java @@ -110,6 +110,8 @@ public class CommsTransport extends Thread implements TransportProcs { m_socketChannel.register( m_selector, ops ); m_selector.select(); } catch ( ClosedChannelException cce ) { + // we get this when relay goes down. Need to notify! + m_jniThread.handle( JNICmd.CMD_TRANSFAIL ); Utils.logf( "exiting: " + cce.toString() ); break; } catch ( java.io.IOException ioe ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java index 6d09d1193..be32d81a0 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/JNIThread.java @@ -22,6 +22,7 @@ public class JNIThread extends Thread { CMD_START, CMD_DO, CMD_RECEIVE, + CMD_TRANSFAIL, CMD_PREFS_CHANGE, CMD_PEN_DOWN, CMD_PEN_MOVE, @@ -288,6 +289,10 @@ public class JNIThread extends Thread { handle( JNICmd.CMD_DO ); break; + case CMD_TRANSFAIL: + XwJNI.comms_transportFailed( m_jniGamePtr ); + break; + case CMD_PREFS_CHANGE: // need to inval all because some of prefs, // e.g. colors, aren't known by common code so diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java index e96f89d86..1d0b99c59 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/XwJNI.java @@ -160,6 +160,7 @@ public class XwJNI { public static native void comms_getAddr( int gamePtr, CommsAddrRec addr ); public static native void comms_setAddr( int gamePtr, CommsAddrRec addr ); public static native void comms_resendAll( int gamePtr ); + public static native void comms_transportFailed( int gamePtr ); // Dicts public static native boolean dict_tilesAreSame( int dictPtr1, int dictPtr2 );