mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-02 20:46:15 +01:00
for testing relay switch, add optional override of hostname
This commit is contained in:
parent
d4e5c9dfdf
commit
04c263fe28
5 changed files with 21 additions and 8 deletions
|
@ -46,6 +46,7 @@ public class CommsTransport implements TransportProcs,
|
||||||
private SocketChannel m_socketChannel;
|
private SocketChannel m_socketChannel;
|
||||||
private int m_jniGamePtr;
|
private int m_jniGamePtr;
|
||||||
private CommsAddrRec m_relayAddr;
|
private CommsAddrRec m_relayAddr;
|
||||||
|
private String m_useHost;
|
||||||
private JNIThread m_jniThread;
|
private JNIThread m_jniThread;
|
||||||
private CommsThread m_thread;
|
private CommsThread m_thread;
|
||||||
private TransportProcs.TPMsgHandler m_tpHandler;
|
private TransportProcs.TPMsgHandler m_tpHandler;
|
||||||
|
@ -99,8 +100,7 @@ public class CommsTransport implements TransportProcs,
|
||||||
DbgUtils.loge( ioe );
|
DbgUtils.loge( ioe );
|
||||||
} catch ( UnresolvedAddressException uae ) {
|
} catch ( UnresolvedAddressException uae ) {
|
||||||
DbgUtils.logf( "bad address: name: %s; port: %s; exception: %s",
|
DbgUtils.logf( "bad address: name: %s; port: %s; exception: %s",
|
||||||
m_relayAddr.ip_relay_hostName,
|
m_useHost, m_relayAddr.ip_relay_port,
|
||||||
m_relayAddr.ip_relay_port,
|
|
||||||
uae.toString() );
|
uae.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,10 +128,10 @@ public class CommsTransport implements TransportProcs,
|
||||||
m_socketChannel = SocketChannel.open();
|
m_socketChannel = SocketChannel.open();
|
||||||
m_socketChannel.configureBlocking( false );
|
m_socketChannel.configureBlocking( false );
|
||||||
DbgUtils.logf( "connecting to %s:%d",
|
DbgUtils.logf( "connecting to %s:%d",
|
||||||
m_relayAddr.ip_relay_hostName,
|
m_useHost,
|
||||||
m_relayAddr.ip_relay_port );
|
m_relayAddr.ip_relay_port );
|
||||||
InetSocketAddress isa = new
|
InetSocketAddress isa = new
|
||||||
InetSocketAddress(m_relayAddr.ip_relay_hostName,
|
InetSocketAddress(m_useHost,
|
||||||
m_relayAddr.ip_relay_port );
|
m_relayAddr.ip_relay_port );
|
||||||
m_socketChannel.connect( isa );
|
m_socketChannel.connect( isa );
|
||||||
} catch ( java.io.IOException ioe ) {
|
} catch ( java.io.IOException ioe ) {
|
||||||
|
@ -368,6 +368,7 @@ public class CommsTransport implements TransportProcs,
|
||||||
if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY
|
if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY
|
||||||
&& null == m_relayAddr ) {
|
&& null == m_relayAddr ) {
|
||||||
m_relayAddr = new CommsAddrRec( addr );
|
m_relayAddr = new CommsAddrRec( addr );
|
||||||
|
m_useHost = NetUtils.forceHost( m_relayAddr.ip_relay_hostName );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY ) {
|
if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY ) {
|
||||||
|
|
|
@ -441,10 +441,11 @@ public class NetLaunchInfo {
|
||||||
public Uri makeLaunchUri( Context context )
|
public Uri makeLaunchUri( Context context )
|
||||||
{
|
{
|
||||||
int addrs = m_addrs.toInt();
|
int addrs = m_addrs.toInt();
|
||||||
|
String host = LocUtils.getString( context, R.string.invite_host );
|
||||||
|
host = NetUtils.forceHost( host );
|
||||||
Uri.Builder ub = new Uri.Builder()
|
Uri.Builder ub = new Uri.Builder()
|
||||||
.scheme( "http" )
|
.scheme( "http" )
|
||||||
.path( String.format( "//%s%s",
|
.path( String.format( "//%s%s", host,
|
||||||
LocUtils.getString(context, R.string.invite_host),
|
|
||||||
LocUtils.getString(context, R.string.invite_prefix) ) );
|
LocUtils.getString(context, R.string.invite_prefix) ) );
|
||||||
appendInt( ub, LANG_KEY, lang );
|
appendInt( ub, LANG_KEY, lang );
|
||||||
appendInt( ub, TOTPLAYERS_KEY, nPlayersT );
|
appendInt( ub, TOTPLAYERS_KEY, nPlayersT );
|
||||||
|
|
|
@ -198,6 +198,14 @@ public class NetUtils {
|
||||||
return msgs;
|
return msgs;
|
||||||
} // queryRelay
|
} // queryRelay
|
||||||
|
|
||||||
|
public static String forceHost( String host )
|
||||||
|
{
|
||||||
|
if ( 0 < XWApp.FORCE_RELAY_HOST.length() ) {
|
||||||
|
host = XWApp.FORCE_RELAY_HOST;
|
||||||
|
}
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
protected static HttpPost makePost( Context context, String proc )
|
protected static HttpPost makePost( Context context, String proc )
|
||||||
{
|
{
|
||||||
String url = String.format( "%s/%s",
|
String url = String.format( "%s/%s",
|
||||||
|
|
|
@ -45,6 +45,8 @@ public class XWApp extends Application {
|
||||||
public static final boolean UDP_ENABLED = true;
|
public static final boolean UDP_ENABLED = true;
|
||||||
public static final boolean SMS_INVITE_ENABLED = true;
|
public static final boolean SMS_INVITE_ENABLED = true;
|
||||||
public static final boolean LOCUTILS_ENABLED = false;
|
public static final boolean LOCUTILS_ENABLED = false;
|
||||||
|
public static final String FORCE_RELAY_HOST = "";
|
||||||
|
// public static final String FORCE_RELAY_HOST = "eehouse.org";
|
||||||
|
|
||||||
public static final String SMS_PUBLIC_HEADER = "-XW4";
|
public static final String SMS_PUBLIC_HEADER = "-XW4";
|
||||||
public static final int MAX_TRAY_TILES = 7; // comtypes.h
|
public static final int MAX_TRAY_TILES = 7; // comtypes.h
|
||||||
|
|
|
@ -90,7 +90,8 @@ public class XWPrefs {
|
||||||
|
|
||||||
public static String getDefaultRelayHost( Context context )
|
public static String getDefaultRelayHost( Context context )
|
||||||
{
|
{
|
||||||
return getPrefsString( context, R.string.key_relay_host );
|
String host = getPrefsString( context, R.string.key_relay_host );
|
||||||
|
return NetUtils.forceHost( host );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDefaultRelayPort( Context context )
|
public static int getDefaultRelayPort( Context context )
|
||||||
|
|
Loading…
Add table
Reference in a new issue