From de7c29dcc7e3fc610c08b253ead9cfaf430109a9 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 20 Jan 2013 21:33:35 -0800 Subject: [PATCH] add comms_stop() to jni and use it --- xwords4/android/XWords4/jni/xwjni.c | 17 +++++++++++++++-- .../org/eehouse/android/xw4/jni/JNIThread.java | 3 +++ .../src/org/eehouse/android/xw4/jni/XwJNI.java | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 535405ece..eb76f49ff 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -995,8 +995,21 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1start ( JNIEnv* env, jclass C, jint gamePtr ) { XWJNI_START(); - if ( !!state->game.comms ) { - comms_start( state->game.comms ); + CommsCtxt* comms = state->game.comms; + if ( !!comms ) { + comms_start( comms ); + } + XWJNI_END(); +} + +JNIEXPORT void JNICALL +Java_org_eehouse_android_xw4_jni_XwJNI_comms_1stop +( JNIEnv* env, jclass C, jint gamePtr ) +{ + XWJNI_START(); + CommsCtxt* comms = state->game.comms; + if ( !!comms ) { + comms_stop( comms ); } XWJNI_END(); } 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 29c3ebdb0..752b8ea7d 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 @@ -286,6 +286,9 @@ public class JNIThread extends Thread { // state. In some cases it'll otherwise drop the move. XwJNI.server_do( m_jniGamePtr ); + // And let it tell the relay (if any) it's leaving + XwJNI.comms_stop( m_jniGamePtr ); + XwJNI.game_getGi( m_jniGamePtr, m_gi ); if ( null != m_newDict ) { m_gi.dictName = m_newDict; 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 0d869ab06..e25e1ad35 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 @@ -234,6 +234,7 @@ public class XwJNI { // Comms public static native void comms_start( int gamePtr ); + public static native void comms_stop( int gamePtr ); public static native void comms_resetSame( int gamePtr ); public static native void comms_getAddr( int gamePtr, CommsAddrRec addr ); public static native CommsAddrRec[] comms_getAddrs( int gamePtr );