mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +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 int m_jniGamePtr;
|
||||
private CommsAddrRec m_relayAddr;
|
||||
private String m_useHost;
|
||||
private JNIThread m_jniThread;
|
||||
private CommsThread m_thread;
|
||||
private TransportProcs.TPMsgHandler m_tpHandler;
|
||||
|
@ -99,8 +100,7 @@ public class CommsTransport implements TransportProcs,
|
|||
DbgUtils.loge( ioe );
|
||||
} catch ( UnresolvedAddressException uae ) {
|
||||
DbgUtils.logf( "bad address: name: %s; port: %s; exception: %s",
|
||||
m_relayAddr.ip_relay_hostName,
|
||||
m_relayAddr.ip_relay_port,
|
||||
m_useHost, m_relayAddr.ip_relay_port,
|
||||
uae.toString() );
|
||||
}
|
||||
|
||||
|
@ -127,11 +127,11 @@ public class CommsTransport implements TransportProcs,
|
|||
try {
|
||||
m_socketChannel = SocketChannel.open();
|
||||
m_socketChannel.configureBlocking( false );
|
||||
DbgUtils.logf( "connecting to %s:%d",
|
||||
m_relayAddr.ip_relay_hostName,
|
||||
DbgUtils.logf( "connecting to %s:%d",
|
||||
m_useHost,
|
||||
m_relayAddr.ip_relay_port );
|
||||
InetSocketAddress isa = new
|
||||
InetSocketAddress(m_relayAddr.ip_relay_hostName,
|
||||
InetSocketAddress(m_useHost,
|
||||
m_relayAddr.ip_relay_port );
|
||||
m_socketChannel.connect( isa );
|
||||
} catch ( java.io.IOException ioe ) {
|
||||
|
@ -368,6 +368,7 @@ public class CommsTransport implements TransportProcs,
|
|||
if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY
|
||||
&& null == m_relayAddr ) {
|
||||
m_relayAddr = new CommsAddrRec( addr );
|
||||
m_useHost = NetUtils.forceHost( m_relayAddr.ip_relay_hostName );
|
||||
}
|
||||
|
||||
if ( !XWApp.UDP_ENABLED && conType == CommsConnType.COMMS_CONN_RELAY ) {
|
||||
|
|
|
@ -441,10 +441,11 @@ public class NetLaunchInfo {
|
|||
public Uri makeLaunchUri( Context context )
|
||||
{
|
||||
int addrs = m_addrs.toInt();
|
||||
String host = LocUtils.getString( context, R.string.invite_host );
|
||||
host = NetUtils.forceHost( host );
|
||||
Uri.Builder ub = new Uri.Builder()
|
||||
.scheme( "http" )
|
||||
.path( String.format( "//%s%s",
|
||||
LocUtils.getString(context, R.string.invite_host),
|
||||
.path( String.format( "//%s%s", host,
|
||||
LocUtils.getString(context, R.string.invite_prefix) ) );
|
||||
appendInt( ub, LANG_KEY, lang );
|
||||
appendInt( ub, TOTPLAYERS_KEY, nPlayersT );
|
||||
|
|
|
@ -198,6 +198,14 @@ public class NetUtils {
|
|||
return msgs;
|
||||
} // 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 )
|
||||
{
|
||||
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 SMS_INVITE_ENABLED = true;
|
||||
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 int MAX_TRAY_TILES = 7; // comtypes.h
|
||||
|
|
|
@ -90,7 +90,8 @@ public class XWPrefs {
|
|||
|
||||
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 )
|
||||
|
|
Loading…
Add table
Reference in a new issue