mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-20 22:26:54 +01:00
make server_initClientConnection() make its own stream
This commit is contained in:
parent
da639af7c3
commit
15fde8044f
5 changed files with 9 additions and 22 deletions
|
@ -2038,9 +2038,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1initClientConnection
|
||||||
jboolean result;
|
jboolean result;
|
||||||
LOG_FUNC();
|
LOG_FUNC();
|
||||||
XWJNI_START_GLOBALS();
|
XWJNI_START_GLOBALS();
|
||||||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
result = server_initClientConnection( state->game.server, env );
|
||||||
stream_setOnCloseProc( stream, and_send_on_close );
|
|
||||||
result = server_initClientConnection( state->game.server, env, stream );
|
|
||||||
XWJNI_END();
|
XWJNI_END();
|
||||||
LOG_RETURNF( "%s", boolToStr(result) );
|
LOG_RETURNF( "%s", boolToStr(result) );
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -693,7 +693,7 @@ readMQTTDevID( ServerCtxt* server, XWStreamCtxt* stream )
|
||||||
}
|
}
|
||||||
|
|
||||||
XP_Bool
|
XP_Bool
|
||||||
server_initClientConnection( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream )
|
server_initClientConnection( ServerCtxt* server, XWEnv xwe )
|
||||||
{
|
{
|
||||||
XP_Bool result;
|
XP_Bool result;
|
||||||
XP_LOGFF( "gameState: %s; gameID: %d", getStateStr(server->nv.gameState),
|
XP_LOGFF( "gameState: %s; gameID: %d", getStateStr(server->nv.gameState),
|
||||||
|
@ -706,13 +706,10 @@ server_initClientConnection( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XP_ASSERT( gi->serverRole == SERVER_ISCLIENT );
|
XP_ASSERT( gi->serverRole == SERVER_ISCLIENT );
|
||||||
XP_ASSERT( stream != NULL );
|
|
||||||
result = server->nv.gameState == XWSTATE_NONE;
|
result = server->nv.gameState == XWSTATE_NONE;
|
||||||
if ( result ) {
|
if ( result ) {
|
||||||
stream_open( stream );
|
XWStreamCtxt* stream = messageStreamWithHeader( server, xwe, SERVER_DEVICE,
|
||||||
|
XWPROTO_DEVICE_REGISTRATION );
|
||||||
writeProto( server, stream, XWPROTO_DEVICE_REGISTRATION );
|
|
||||||
|
|
||||||
nPlayers = gi->nPlayers;
|
nPlayers = gi->nPlayers;
|
||||||
XP_ASSERT( nPlayers > 0 );
|
XP_ASSERT( nPlayers > 0 );
|
||||||
XP_U16 localPlayers = gi_countLocalPlayers( gi, XP_FALSE);
|
XP_U16 localPlayers = gi_countLocalPlayers( gi, XP_FALSE);
|
||||||
|
@ -747,12 +744,11 @@ server_initClientConnection( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* stream
|
||||||
#ifdef STREAM_VERS_BIGBOARD
|
#ifdef STREAM_VERS_BIGBOARD
|
||||||
stream_putU8( stream, CUR_STREAM_VERS );
|
stream_putU8( stream, CUR_STREAM_VERS );
|
||||||
#endif
|
#endif
|
||||||
|
stream_destroy( stream, xwe );
|
||||||
} else {
|
} else {
|
||||||
XP_LOGFF( "wierd state: %s (expected XWSTATE_NONE); dropping message",
|
XP_LOGFF( "wierd state: %s (expected XWSTATE_NONE); dropping message",
|
||||||
getStateStr(server->nv.gameState) );
|
getStateStr(server->nv.gameState) );
|
||||||
}
|
}
|
||||||
stream_destroy( stream, xwe );
|
|
||||||
return result;
|
return result;
|
||||||
} /* server_initClientConnection */
|
} /* server_initClientConnection */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -115,8 +115,7 @@ XP_Bool server_receiveMessage( ServerCtxt* server, XWEnv xwe, XWStreamCtxt* inco
|
||||||
/* client-side messages. Client (platform code)owns the stream used to talk
|
/* client-side messages. Client (platform code)owns the stream used to talk
|
||||||
* to the server, and passes it in. */
|
* to the server, and passes it in. */
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
XP_Bool server_initClientConnection( ServerCtxt* server, XWEnv xwe,
|
XP_Bool server_initClientConnection( ServerCtxt* server, XWEnv xwe );
|
||||||
XWStreamCtxt* stream );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XWFEATURE_CHAT
|
#ifdef XWFEATURE_CHAT
|
||||||
|
|
|
@ -86,8 +86,8 @@ typedef XP_Bool (*XWTimerProc)( void* closure, XWEnv xwe, XWTimerReason why );
|
||||||
typedef struct UtilVtable {
|
typedef struct UtilVtable {
|
||||||
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
XWStreamCtxt* (*m_util_makeStreamFromAddr )(XW_UtilCtxt* uc, XWEnv xwe,
|
XWStreamCtxt* (*m_util_makeStreamFromAddr)(XW_UtilCtxt* uc, XWEnv xwe,
|
||||||
XP_PlayerAddr channelNo );
|
XP_PlayerAddr channelNo );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XWBonusType (*m_util_getSquareBonus)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 boardSize,
|
XWBonusType (*m_util_getSquareBonus)( XW_UtilCtxt* uc, XWEnv xwe, XP_U16 boardSize,
|
||||||
|
|
|
@ -131,13 +131,7 @@ streamFromFile( CommonGlobals* cGlobals, char* name )
|
||||||
void
|
void
|
||||||
tryConnectToServer( CommonGlobals* cGlobals )
|
tryConnectToServer( CommonGlobals* cGlobals )
|
||||||
{
|
{
|
||||||
LaunchParams* params = cGlobals->params;
|
(void)server_initClientConnection( cGlobals->game.server, NULL_XWE );
|
||||||
XWStreamCtxt* stream =
|
|
||||||
mem_stream_make( MPPARM(cGlobals->util->mpool) params->vtMgr,
|
|
||||||
cGlobals, CHANNEL_NONE,
|
|
||||||
sendOnClose );
|
|
||||||
(void)server_initClientConnection( cGlobals->game.server, NULL_XWE,
|
|
||||||
stream );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue