add new booleans to relay address record around public rooms

This commit is contained in:
Andy2 2010-09-03 06:38:46 -07:00
parent e20c63f38c
commit b742c7dbb7
3 changed files with 27 additions and 3 deletions

View file

@ -179,7 +179,6 @@ setObject( JNIEnv* env, jobject obj, const char* name, const char* sig,
(*env)->DeleteLocalRef( env, cls ); (*env)->DeleteLocalRef( env, cls );
} }
/* return false on failure, e.g. exception raised */
bool bool
getBool( JNIEnv* env, jobject obj, const char* name ) getBool( JNIEnv* env, jobject obj, const char* name )
{ {
@ -313,6 +312,10 @@ setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr )
setInt( env, jaddr, "ip_relay_port", addr->u.ip_relay.port ); setInt( env, jaddr, "ip_relay_port", addr->u.ip_relay.port );
setString( env, jaddr, "ip_relay_hostName", addr->u.ip_relay.hostName ); setString( env, jaddr, "ip_relay_hostName", addr->u.ip_relay.hostName );
setString( env, jaddr, "ip_relay_invite", addr->u.ip_relay.invite ); setString( env, jaddr, "ip_relay_invite", addr->u.ip_relay.invite );
setBool( env, jaddr, "ip_relay_seeksPublicRoom",
addr->u.ip_relay.seeksPublicRoom );
setBool( env, jaddr, "ip_relay_advertiseRoom",
addr->u.ip_relay.advertiseRoom );
break; break;
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
setString( env, jaddr, "sms_phone", addr->u.sms.phone ); setString( env, jaddr, "sms_phone", addr->u.sms.phone );
@ -341,6 +344,11 @@ getJAddrRec( JNIEnv* env, CommsAddrRec* addr, jobject jaddr )
VSIZE(addr->u.ip_relay.hostName) ); VSIZE(addr->u.ip_relay.hostName) );
getString( env, jaddr, "ip_relay_invite", addr->u.ip_relay.invite, getString( env, jaddr, "ip_relay_invite", addr->u.ip_relay.invite,
VSIZE(addr->u.ip_relay.invite) ); VSIZE(addr->u.ip_relay.invite) );
addr->u.ip_relay.seeksPublicRoom =
getBool( env, jaddr, "ip_relay_seeksPublicRoom" );
addr->u.ip_relay.advertiseRoom =
getBool( env, jaddr, "ip_relay_advertiseRoom" );
break; break;
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
getString( env, jaddr, "sms_phone", addr->u.sms.phone, getString( env, jaddr, "sms_phone", addr->u.sms.phone,

View file

@ -431,6 +431,10 @@ addrFromStream( CommsAddrRec* addrP, XWStreamCtxt* stream )
sizeof(addr.u.ip_relay.hostName) ); sizeof(addr.u.ip_relay.hostName) );
addr.u.ip_relay.ipAddr = stream_getU32( stream ); addr.u.ip_relay.ipAddr = stream_getU32( stream );
addr.u.ip_relay.port = stream_getU16( stream ); addr.u.ip_relay.port = stream_getU16( stream );
if ( stream_getVersion( stream ) >= STREAM_VERS_DICTLANG ) {
addr.u.ip_relay.seeksPublicRoom = stream_getBits( stream, 1 );
addr.u.ip_relay.advertiseRoom = stream_getBits( stream, 1 );
}
break; break;
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
stringFromStreamHere( stream, addr.u.sms.phone, stringFromStreamHere( stream, addr.u.sms.phone,
@ -605,8 +609,8 @@ static void
addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addrP ) addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addrP )
{ {
CommsAddrRec addr; CommsAddrRec addr;
XP_MEMCPY( &addr, addrP, sizeof(addr) ); XP_MEMCPY( &addr, addrP, sizeof(addr) ); /* does this really speed things
or reduce code size? */
stream_putU8( stream, addr.conType ); stream_putU8( stream, addr.conType );
switch( addr.conType ) { switch( addr.conType ) {
@ -632,6 +636,8 @@ addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addrP )
stringToStream( stream, addr.u.ip_relay.hostName ); stringToStream( stream, addr.u.ip_relay.hostName );
stream_putU32( stream, addr.u.ip_relay.ipAddr ); stream_putU32( stream, addr.u.ip_relay.ipAddr );
stream_putU16( stream, addr.u.ip_relay.port ); stream_putU16( stream, addr.u.ip_relay.port );
stream_putBits( stream, 1, addr.u.ip_relay.seeksPublicRoom );
stream_putBits( stream, 1, addr.u.ip_relay.advertiseRoom );
break; break;
case COMMS_CONN_SMS: case COMMS_CONN_SMS:
stringToStream( stream, addr.u.sms.phone ); stringToStream( stream, addr.u.sms.phone );
@ -715,6 +721,8 @@ comms_getAddr( const CommsCtxt* comms, CommsAddrRec* addr )
void void
comms_setAddr( CommsCtxt* comms, const CommsAddrRec* addr ) comms_setAddr( CommsCtxt* comms, const CommsAddrRec* addr )
{ {
XP_LOGF( "%s: seeksPublicRoom: %d", __func__,
addr->u.ip_relay.seeksPublicRoom );
XP_ASSERT( comms != NULL ); XP_ASSERT( comms != NULL );
util_addrChange( comms->util, &comms->addr, addr ); util_addrChange( comms->util, &comms->addr, addr );
XP_MEMCPY( &comms->addr, addr, sizeof(comms->addr) ); XP_MEMCPY( &comms->addr, addr, sizeof(comms->addr) );
@ -1857,6 +1865,8 @@ send_via_relay( CommsCtxt* comms, XWRELAY_Cmd cmd, XWHostID destID,
case XWRELAY_GAME_RECONNECT: case XWRELAY_GAME_RECONNECT:
stream_putU8( tmpStream, XWRELAY_PROTO_VERSION ); stream_putU8( tmpStream, XWRELAY_PROTO_VERSION );
stringToStream( tmpStream, addr.u.ip_relay.invite ); stringToStream( tmpStream, addr.u.ip_relay.invite );
stream_putU8( tmpStream, addr.u.ip_relay.seeksPublicRoom );
stream_putU8( tmpStream, addr.u.ip_relay.advertiseRoom );
stream_putU8( tmpStream, comms->r.myHostID ); stream_putU8( tmpStream, comms->r.myHostID );
XP_ASSERT( cmd == XWRELAY_GAME_RECONNECT XP_ASSERT( cmd == XWRELAY_GAME_RECONNECT
|| comms->r.myHostID == HOST_ID_NONE || comms->r.myHostID == HOST_ID_NONE
@ -1866,6 +1876,10 @@ send_via_relay( CommsCtxt* comms, XWRELAY_Cmd cmd, XWHostID destID,
stream_putU16( tmpStream, getChannelSeed(comms) ); stream_putU16( tmpStream, getChannelSeed(comms) );
if ( XWRELAY_GAME_RECONNECT == cmd ) { if ( XWRELAY_GAME_RECONNECT == cmd ) {
stringToStream( tmpStream, comms->r.connName ); stringToStream( tmpStream, comms->r.connName );
} else {
const CurGameInfo* gameInfo = comms->util->gameInfo;
stream_putU8( tmpStream, gameInfo->dictLang );
XP_LOGF( "%s: langCode=%d", __func__, gameInfo->dictLang );
} }
set_relay_state( comms, COMMS_RELAYSTATE_CONNECT_PENDING ); set_relay_state( comms, COMMS_RELAYSTATE_CONNECT_PENDING );
break; break;

View file

@ -91,6 +91,8 @@ typedef struct CommsAddrRec {
XP_UCHAR hostName[MAX_HOSTNAME_LEN + 1]; XP_UCHAR hostName[MAX_HOSTNAME_LEN + 1];
XP_U32 ipAddr; /* looked up from above */ XP_U32 ipAddr; /* looked up from above */
XP_U16 port; XP_U16 port;
XP_Bool seeksPublicRoom;
XP_Bool advertiseRoom;
} ip_relay; } ip_relay;
struct { struct {
/* nothing? */ /* nothing? */