From 6f07098cf392665058c66ca376ff56f947cd3c99 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 14 Sep 2014 13:42:11 -0700 Subject: [PATCH] return succes from server_initClientConnection() --- xwords4/android/XWords4/jni/xwjni.c | 8 +++++--- xwords4/common/server.h | 2 +- xwords4/linux/cursesmain.c | 17 ++++++----------- xwords4/linux/gtkboard.c | 8 ++++---- xwords4/linux/linuxmain.c | 3 ++- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/xwords4/android/XWords4/jni/xwjni.c b/xwords4/android/XWords4/jni/xwjni.c index 1f88874a6..08d921e8f 100644 --- a/xwords4/android/XWords4/jni/xwjni.c +++ b/xwords4/android/XWords4/jni/xwjni.c @@ -1177,17 +1177,19 @@ and_send_on_close( XWStreamCtxt* stream, void* closure ) comms_send( state->game.comms, stream ); } -JNIEXPORT void JNICALL +JNIEXPORT jboolean JNICALL Java_org_eehouse_android_xw4_jni_XwJNI_server_1initClientConnection ( JNIEnv* env, jclass C, jint gamePtr ) { + jboolean result; LOG_FUNC(); XWJNI_START_GLOBALS(); XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals ); stream_setOnCloseProc( stream, and_send_on_close ); - server_initClientConnection( state->game.server, stream ); + result = server_initClientConnection( state->game.server, stream ); XWJNI_END(); - LOG_RETURN_VOID(); + LOG_RETURNF( "%d", result ); + return result; } JNIEXPORT void JNICALL diff --git a/xwords4/common/server.h b/xwords4/common/server.h index 73c21e52f..f45e2e163 100644 --- a/xwords4/common/server.h +++ b/xwords4/common/server.h @@ -116,7 +116,7 @@ XP_Bool server_receiveMessage( ServerCtxt* server, XWStreamCtxt* incoming ); /* client-side messages. Client (platform code)owns the stream used to talk * to the server, and passes it in. */ #ifndef XWFEATURE_STANDALONE_ONLY -void server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream ); +XP_Bool server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream ); #endif #ifdef XWFEATURE_CHAT diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index fbe673256..5d64e603c 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -2168,17 +2168,12 @@ cursesmain( XP_Bool isServer, LaunchParams* params ) #ifndef XWFEATURE_STANDALONE_ONLY /* send any events that need to get off before the event loop begins */ if ( !isServer ) { - if ( 1 /* stream_open( params->info.clientInfo.stream ) */) { - server_initClientConnection( cGlobals->game.server, - mem_stream_make( MEMPOOL - params->vtMgr, - cGlobals, - (XP_PlayerAddr)0, - sendOnClose ) ); - } else { - cursesUserError( &g_globals, "Unable to open connection to server"); - exit( 0 ); - } + (void)server_initClientConnection( cGlobals->game.server, + mem_stream_make( MEMPOOL + params->vtMgr, + cGlobals, + (XP_PlayerAddr)0, + sendOnClose ) ); } #endif diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c index 06ed49b62..7b5a0842b 100644 --- a/xwords4/linux/gtkboard.c +++ b/xwords4/linux/gtkboard.c @@ -578,8 +578,8 @@ createOrLoadObjects( GtkGameGlobals* globals ) mem_stream_make( MEMPOOL params->vtMgr, cGlobals, CHANNEL_NONE, sendOnClose ); - server_initClientConnection( cGlobals->game.server, - stream ); + (void)server_initClientConnection( cGlobals->game.server, + stream ); } #endif } @@ -945,8 +945,8 @@ new_game_impl( GtkGameGlobals* globals, XP_Bool fireConnDlg ) mem_stream_make( MEMPOOL globals->cGlobals.params->vtMgr, &globals->cGlobals, CHANNEL_NONE, sendOnClose ); - server_initClientConnection( globals->cGlobals.game.server, - stream ); + (void)server_initClientConnection( globals->cGlobals.game.server, + stream ); } #endif (void)server_do( globals->cGlobals.game.server ); /* assign tiles, etc. */ diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 3ae938838..26d0f6da8 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -1439,7 +1439,8 @@ linuxChangeRoles( CommonGlobals* cGlobals ) XWStreamCtxt* stream = mem_stream_make( MPPARM(cGlobals->util->mpool) cGlobals->params->vtMgr, cGlobals, CHANNEL_NONE, sendOnClose ); - server_initClientConnection( server, stream ); + XP_Bool done = server_initClientConnection( server, stream ); + XP_ASSERT( !done ); } (void)server_do( server ); }