mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
add param to comms_resendAll to limit type of message sent
(e.g. BT). Meant to be used when a single type has become available.
This commit is contained in:
parent
9c6908d14a
commit
19713a40ad
7 changed files with 32 additions and 17 deletions
|
@ -1805,19 +1805,24 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1changeDict
|
|||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_comms_1resendAll
|
||||
( JNIEnv* env, jclass C, GamePtrType gamePtr, jboolean force, jboolean thenAck )
|
||||
( JNIEnv* env, jclass C, GamePtrType gamePtr, jboolean force, jobject jFilter,
|
||||
jboolean thenAck )
|
||||
{
|
||||
LOG_FUNC();
|
||||
jint result;
|
||||
XWJNI_START();
|
||||
CommsCtxt* comms = state->game.comms;
|
||||
XP_ASSERT( !!comms );
|
||||
result = comms_resendAll( comms, force );
|
||||
CommsConnType filter =
|
||||
NULL == jFilter ? COMMS_CONN_NONE : jEnumToInt( env, jFilter );
|
||||
result = comms_resendAll( comms, filter, force );
|
||||
if ( thenAck ) {
|
||||
#ifdef XWFEATURE_COMMSACK
|
||||
comms_ackAny( comms );
|
||||
#endif
|
||||
}
|
||||
XWJNI_END();
|
||||
LOG_RETURNF( "%d", result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1218,7 +1218,7 @@ public class GameUtils {
|
|||
m_sink = new MultiMsgSink( m_context, rowid );
|
||||
GamePtr gamePtr = loadMakeGame( m_context, gi, m_sink, lock );
|
||||
if ( null != gamePtr ) {
|
||||
XwJNI.comms_resendAll( gamePtr.ptr(), true, false );
|
||||
XwJNI.comms_resendAll( gamePtr.ptr(), true, m_filter, false );
|
||||
gamePtr.release();
|
||||
}
|
||||
lock.unlock();
|
||||
|
|
|
@ -362,7 +362,12 @@ public class XwJNI {
|
|||
public static native CommsAddrRec[] comms_getAddrs( int gamePtr );
|
||||
public static native void comms_setAddr( int gamePtr, CommsAddrRec addr );
|
||||
public static native int comms_resendAll( int gamePtr, boolean force,
|
||||
CommsConnType filter,
|
||||
boolean andAck );
|
||||
public static int comms_resendAll( int gamePtr, boolean force,
|
||||
boolean andAck ) {
|
||||
return comms_resendAll( gamePtr, force, null, andAck );
|
||||
}
|
||||
public static native void comms_ackAny( int gamePtr );
|
||||
public static native void comms_transportFailed( int gamePtr,
|
||||
CommsConnType failed );
|
||||
|
|
|
@ -193,7 +193,7 @@ static XP_Bool channelToAddress( CommsCtxt* comms, XP_PlayerAddr channelNo,
|
|||
const CommsAddrRec** addr );
|
||||
static AddressRecord* getRecordFor( CommsCtxt* comms, const CommsAddrRec* addr,
|
||||
XP_PlayerAddr channelNo, XP_Bool maskChnl );
|
||||
static XP_S16 sendMsg( CommsCtxt* comms, MsgQueueElem* elem );
|
||||
static XP_S16 sendMsg( CommsCtxt* comms, MsgQueueElem* elem, CommsConnType filter );
|
||||
static MsgQueueElem* addToQueue( CommsCtxt* comms, MsgQueueElem* newMsgElem );
|
||||
static XP_Bool elems_same( const MsgQueueElem* e1, const MsgQueueElem* e2 ) ;
|
||||
static void freeElem( const CommsCtxt* comms, MsgQueueElem* elem );
|
||||
|
@ -778,7 +778,7 @@ sendConnect( CommsCtxt* comms, XP_Bool breakExisting )
|
|||
case COMMS_CONN_IP_DIRECT:
|
||||
/* This will only work on host side when there's a single guest! */
|
||||
(void)send_via_bt_or_ip( comms, BTIPMSG_RESET, CHANNEL_NONE, typ, NULL, 0, NULL );
|
||||
(void)comms_resendAll( comms, XP_FALSE );
|
||||
(void)comms_resendAll( comms, COMMS_CONN_NONE, XP_FALSE );
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
@ -1181,7 +1181,7 @@ comms_send( CommsCtxt* comms, XWStreamCtxt* stream )
|
|||
if ( NULL != elem ) {
|
||||
elem = addToQueue( comms, elem );
|
||||
printQueue( comms );
|
||||
result = sendMsg( comms, elem );
|
||||
result = sendMsg( comms, elem, COMMS_CONN_NONE );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -1362,7 +1362,7 @@ gameID( const CommsCtxt* comms )
|
|||
}
|
||||
|
||||
static XP_S16
|
||||
sendMsg( CommsCtxt* comms, MsgQueueElem* elem )
|
||||
sendMsg( CommsCtxt* comms, MsgQueueElem* elem, const CommsConnType filter )
|
||||
{
|
||||
XP_S16 result = -1;
|
||||
XP_PlayerAddr channelNo = elem->channelNo;
|
||||
|
@ -1379,6 +1379,9 @@ sendMsg( CommsCtxt* comms, MsgQueueElem* elem )
|
|||
if ( comms_getAddrDisabled( comms, typ, XP_TRUE ) ) {
|
||||
XP_LOGF( "%s: dropping message because %s disabled", __func__,
|
||||
ConnType2Str( typ ) );
|
||||
} else if ( COMMS_CONN_NONE != filter && filter != typ ) {
|
||||
XP_LOGF( "%s: dropping message because not of type %s", __func__,
|
||||
ConnType2Str( filter ) );
|
||||
} else {
|
||||
XP_LOGF( TAGFMT() "sending msg with sum %s using typ %s", TAGPRMS,
|
||||
elem->checksum, ConnType2Str(typ) );
|
||||
|
@ -1468,7 +1471,7 @@ send_ack( CommsCtxt* comms )
|
|||
}
|
||||
|
||||
XP_S16
|
||||
comms_resendAll( CommsCtxt* comms, XP_Bool force )
|
||||
comms_resendAll( CommsCtxt* comms, CommsConnType filter, XP_Bool force )
|
||||
{
|
||||
XP_S16 count = 0;
|
||||
XP_Bool success = XP_TRUE;
|
||||
|
@ -1484,7 +1487,7 @@ comms_resendAll( CommsCtxt* comms, XP_Bool force )
|
|||
MsgQueueElem* msg;
|
||||
|
||||
for ( msg = comms->msgQueueHead; !!msg; msg = msg->next ) {
|
||||
XP_S16 len = sendMsg( comms, msg );
|
||||
XP_S16 len = sendMsg( comms, msg, filter );
|
||||
if ( 0 > len ) {
|
||||
success = XP_FALSE;
|
||||
break;
|
||||
|
@ -1664,7 +1667,7 @@ relayPreProcess( CommsCtxt* comms, XWStreamCtxt* stream, XWHostID* senderID )
|
|||
break;
|
||||
case XWRELAY_RECONNECT_RESP:
|
||||
got_connect_cmd( comms, stream, XP_TRUE );
|
||||
comms_resendAll( comms, XP_FALSE );
|
||||
comms_resendAll( comms, COMMS_CONN_NONE, XP_FALSE );
|
||||
break;
|
||||
|
||||
case XWRELAY_ALLHERE:
|
||||
|
@ -1709,7 +1712,7 @@ relayPreProcess( CommsCtxt* comms, XWStreamCtxt* stream, XWHostID* senderID )
|
|||
on RECONNECTED, so removing the test for now to fix recon
|
||||
problems on android. */
|
||||
/* if ( COMMS_RELAYSTATE_RECONNECTED != comms->rr.relayState ) { */
|
||||
comms_resendAll( comms, XP_FALSE );
|
||||
comms_resendAll( comms, COMMS_CONN_NONE, XP_FALSE );
|
||||
/* } */
|
||||
if ( XWRELAY_ALLHERE == cmd ) { /* initial connect? */
|
||||
(*comms->procs.rconnd)( comms->procs.closure,
|
||||
|
@ -2341,7 +2344,7 @@ sendEmptyMsg( CommsCtxt* comms, AddressRecord* rec )
|
|||
0 /*rec? rec->lastMsgRcd : 0*/,
|
||||
rec,
|
||||
rec? rec->channelNo : 0, NULL );
|
||||
(void)sendMsg( comms, elem );
|
||||
(void)sendMsg( comms, elem, COMMS_CONN_NONE );
|
||||
freeElem( comms, elem );
|
||||
} /* sendEmptyMsg */
|
||||
#endif
|
||||
|
|
|
@ -219,7 +219,7 @@ void addrFromStream( CommsAddrRec* addr, XWStreamCtxt* stream );
|
|||
void addrToStream( XWStreamCtxt* stream, const CommsAddrRec* addr );
|
||||
|
||||
XP_S16 comms_send( CommsCtxt* comms, XWStreamCtxt* stream );
|
||||
XP_S16 comms_resendAll( CommsCtxt* comms, XP_Bool force );
|
||||
XP_S16 comms_resendAll( CommsCtxt* comms, CommsConnType filter, XP_Bool force );
|
||||
XP_U16 comms_getChannelSeed( CommsCtxt* comms );
|
||||
|
||||
#ifdef XWFEATURE_COMMSACK
|
||||
|
|
|
@ -585,7 +585,8 @@ static XP_Bool
|
|||
handleResend( CursesAppGlobals* globals )
|
||||
{
|
||||
if ( !!globals->cGlobals.game.comms ) {
|
||||
comms_resendAll( globals->cGlobals.game.comms, XP_TRUE );
|
||||
comms_resendAll( globals->cGlobals.game.comms, COMMS_CONN_NONE,
|
||||
XP_TRUE );
|
||||
}
|
||||
return XP_TRUE;
|
||||
}
|
||||
|
|
|
@ -1182,7 +1182,7 @@ handle_resend( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
|
|||
{
|
||||
CommsCtxt* comms = globals->cGlobals.game.comms;
|
||||
if ( comms != NULL ) {
|
||||
comms_resendAll( comms, XP_TRUE );
|
||||
comms_resendAll( comms, COMMS_CONN_NONE, XP_TRUE );
|
||||
}
|
||||
} /* handle_resend */
|
||||
|
||||
|
@ -2518,7 +2518,7 @@ gtk_socket_added( void* closure, int newSock, GIOFunc proc )
|
|||
CommsAddrRec addr;
|
||||
comms_getAddr( comms, &addr );
|
||||
if ( (comms != NULL) && (addr_hasType( &addr, COMMS_CONN_BT) ) ) {
|
||||
comms_resendAll( comms, XP_FALSE );
|
||||
comms_resendAll( comms, COMMS_CONN_NONE, XP_FALSE );
|
||||
}
|
||||
LOG_RETURN_VOID();
|
||||
} /* gtk_socket_changed */
|
||||
|
@ -2807,7 +2807,8 @@ loadGameNoDraw( GtkGameGlobals* globals, LaunchParams* params,
|
|||
XP_LOGF( "%s: game loaded", __func__ );
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
if ( !!globals->cGlobals.game.comms ) {
|
||||
comms_resendAll( globals->cGlobals.game.comms, XP_FALSE );
|
||||
comms_resendAll( globals->cGlobals.game.comms, COMMS_CONN_NONE,
|
||||
XP_FALSE );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue