diff --git a/xwords4/android/XWords4/jni/Android.mk b/xwords4/android/XWords4/jni/Android.mk index b03588fe2..651095f79 100644 --- a/xwords4/android/XWords4/jni/Android.mk +++ b/xwords4/android/XWords4/jni/Android.mk @@ -14,7 +14,6 @@ local_DEBUG = -DMEM_DEBUG -DDEBUG -DENABLE_LOGGING local_DEFINES += \ $(local_DEBUG) \ -DXWFEATURE_RELAY \ - -DRELAY_NAME_DEFAULT=\"eehouse.org\" \ -DRELAY_PORT_DEFAULT=10999 \ -DXWFEATURE_TURNCHANGENOTIFY \ -DKEYBOARD_NAV \ diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 48cf07f71..4d771000d 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -227,11 +227,13 @@ Java_org_eehouse_android_xw4_jni_XwJNI_gi_1from_1stream JNIEXPORT void JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_comms_1getInitialAddr -( JNIEnv* env, jclass C, jobject jaddr ) +( JNIEnv* env, jclass C, jobject jaddr, jstring jname ) { - LOG_FUNC(); CommsAddrRec addr; - comms_getInitialAddr( &addr ); + + const char* chars = (*env)->GetStringUTFChars( env, jname, NULL ); + comms_getInitialAddr( &addr, chars ); + (*env)->ReleaseStringUTFChars( env, jname, chars ); setJAddrRec( env, jaddr, &addr ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java index 72b269f6d..6e1dc0de8 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfig.java @@ -343,7 +343,8 @@ public class GameConfig extends Activity implements View.OnClickListener { if ( XwJNI.game_hasComms( gamePtr ) ) { XwJNI.comms_getAddr( gamePtr, m_carOrig ); } else { - XwJNI.comms_getInitialAddr( m_carOrig ); + String relayName = CommonPrefs.getDefaultRelayHost(); + XwJNI.comms_getInitialAddr( m_carOrig, relayName ); } XwJNI.game_dispose( gamePtr ); 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 1c8bd98d1..c8d0518a3 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 @@ -21,7 +21,8 @@ public class XwJNI { // Stateless methods public static native byte[] gi_to_stream( CurGameInfo gi ); public static native void gi_from_stream( CurGameInfo gi, byte[] stream ); - public static native void comms_getInitialAddr( CommsAddrRec addr ); + public static native void comms_getInitialAddr( CommsAddrRec addr, + String relayHost ); // Game methods public static native int initJNI(); diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 84f3c3eff..cbc4aaf46 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -719,14 +719,18 @@ comms_setAddr( CommsCtxt* comms, const CommsAddrRec* addr ) } /* comms_setAddr */ void -comms_getInitialAddr( CommsAddrRec* addr ) +comms_getInitialAddr( CommsAddrRec* addr +#ifdef XWFEATURE_RELAY + , const XP_UCHAR* relayName +#endif + ) { #if defined XWFEATURE_RELAY addr->conType = COMMS_CONN_RELAY; /* for temporary ease in debugging */ addr->u.ip_relay.ipAddr = 0L; /* force 'em to set it */ addr->u.ip_relay.port = RELAY_PORT_DEFAULT; { - char* name = RELAY_NAME_DEFAULT; + const char* name = relayName; char* room = RELAY_ROOM_DEFAULT; XP_MEMCPY( addr->u.ip_relay.hostName, name, XP_STRLEN(name)+1 ); XP_MEMCPY( addr->u.ip_relay.invite, room, XP_STRLEN(room)+1 ); diff --git a/xwords4/common/comms.h b/xwords4/common/comms.h index 2793e7a10..dcf615380 100644 --- a/xwords4/common/comms.h +++ b/xwords4/common/comms.h @@ -149,7 +149,11 @@ void comms_destroy( CommsCtxt* comms ); void comms_setConnID( CommsCtxt* comms, XP_U32 connID ); /* "static" methods work when no comms present */ -void comms_getInitialAddr( CommsAddrRec* addr ); +void comms_getInitialAddr( CommsAddrRec* addr +#ifdef XWFEATURE_RELAY + , const XP_UCHAR* relayName +#endif + ); XP_Bool comms_checkAddr( DeviceRole role, const CommsAddrRec* addr, XW_UtilCtxt* util );