mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
recover a bit better from messages not meant for me, as is happening
when a devices sends to self via SMS and client winds up getting a registration message it just sent. Not perfect yet (and may require a change in the comms protocol -- that's not versioned :-(.
This commit is contained in:
parent
45d3c1fd78
commit
9caeff4a5e
1 changed files with 23 additions and 17 deletions
|
@ -221,6 +221,12 @@ syncPlayers( ServerCtxt* server )
|
||||||
# define syncPlayers( server )
|
# define syncPlayers( server )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static XP_Bool
|
||||||
|
amServer( const ServerCtxt* server )
|
||||||
|
{
|
||||||
|
return SERVER_ISSERVER == server->vol.gi->serverRole;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
initServer( ServerCtxt* server )
|
initServer( ServerCtxt* server )
|
||||||
{
|
{
|
||||||
|
@ -692,26 +698,26 @@ handleRegistrationMsg( ServerCtxt* server, XWStreamCtxt* stream )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( success ) {
|
||||||
#ifdef STREAM_VERS_BIGBOARD
|
#ifdef STREAM_VERS_BIGBOARD
|
||||||
if ( 0 < stream_getSize(stream) ) {
|
if ( 0 < stream_getSize(stream) ) {
|
||||||
XP_U8 streamVersion = stream_getU8( stream );
|
XP_U8 streamVersion = stream_getU8( stream );
|
||||||
if ( streamVersion >= STREAM_VERS_BIGBOARD ) {
|
if ( streamVersion >= STREAM_VERS_BIGBOARD ) {
|
||||||
XP_LOGF( "%s: upping device %d streamVersion to %d",
|
XP_LOGF( "%s: upping device %d streamVersion to %d",
|
||||||
__func__, clientIndex, streamVersion );
|
__func__, clientIndex, streamVersion );
|
||||||
server->nv.addresses[clientIndex].streamVersion = streamVersion;
|
server->nv.addresses[clientIndex].streamVersion = streamVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( server->nv.pendingRegistrations == 0 ) {
|
if ( server->nv.pendingRegistrations == 0 ) {
|
||||||
XP_ASSERT( ii == playersInMsg ); /* otherwise malformed */
|
XP_ASSERT( ii == playersInMsg ); /* otherwise malformed */
|
||||||
setStreamVersion( server );
|
setStreamVersion( server );
|
||||||
checkResizeBoard( server );
|
checkResizeBoard( server );
|
||||||
assignTilesToAll( server );
|
assignTilesToAll( server );
|
||||||
SETSTATE( server, XWSTATE_RECEIVED_ALL_REG );
|
SETSTATE( server, XWSTATE_RECEIVED_ALL_REG );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* now set server's streamVersion if all remote players have the higher one. */
|
|
||||||
/* But first need to pass it in the strramx */
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
} /* handleRegistrationMsg */
|
} /* handleRegistrationMsg */
|
||||||
|
@ -2583,14 +2589,14 @@ server_receiveMessage( ServerCtxt* server, XWStreamCtxt* incoming )
|
||||||
|
|
||||||
printCode( "Receiving", code );
|
printCode( "Receiving", code );
|
||||||
|
|
||||||
if ( code == XWPROTO_DEVICE_REGISTRATION ) {
|
if ( code == XWPROTO_DEVICE_REGISTRATION && amServer(server) ) {
|
||||||
/* This message is special: doesn't have the header that's possible
|
/* This message is special: doesn't have the header that's possible
|
||||||
once the game's in progress and communication's been
|
once the game's in progress and communication's been
|
||||||
established. */
|
established. */
|
||||||
XP_LOGF( "%s: somebody's registering!!!", __func__ );
|
XP_LOGF( "%s: somebody's registering!!!", __func__ );
|
||||||
accepted = handleRegistrationMsg( server, incoming );
|
accepted = handleRegistrationMsg( server, incoming );
|
||||||
|
|
||||||
} else if ( code == XWPROTO_CLIENT_SETUP ) {
|
} else if ( code == XWPROTO_CLIENT_SETUP && !amServer( server ) ) {
|
||||||
|
|
||||||
XP_STATUSF( "client got XWPROTO_CLIENT_SETUP" );
|
XP_STATUSF( "client got XWPROTO_CLIENT_SETUP" );
|
||||||
XP_ASSERT( server->vol.gi->serverRole == SERVER_ISCLIENT );
|
XP_ASSERT( server->vol.gi->serverRole == SERVER_ISCLIENT );
|
||||||
|
|
Loading…
Add table
Reference in a new issue