mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
Implement new callback giving progress connecting with relay.
This commit is contained in:
parent
8450c9da2b
commit
35f068e05c
3 changed files with 58 additions and 6 deletions
|
@ -1406,6 +1406,12 @@ relay_status_curses( void* XP_UNUSED(closure), CommsRelayState state )
|
||||||
XP_LOGF( "%s got status: %s", __func__, CommsRelayState2Str(state) );
|
XP_LOGF( "%s got status: %s", __func__, CommsRelayState2Str(state) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
relay_connd_curses( void* XP_UNUSED(closure), XP_Bool allHere, XP_U16 nMissing )
|
||||||
|
{
|
||||||
|
XP_LOGF( "%s got allHere: %d; nMissing: %d", __func__, allHere, nMissing );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
relay_error_curses( void* XP_UNUSED(closure), XWREASON XP_UNUSED(relayErr) )
|
relay_error_curses( void* XP_UNUSED(closure), XWREASON XP_UNUSED(relayErr) )
|
||||||
{
|
{
|
||||||
|
@ -1478,6 +1484,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
|
||||||
#endif
|
#endif
|
||||||
#ifdef XWFEATURE_RELAY
|
#ifdef XWFEATURE_RELAY
|
||||||
.rstatus = relay_status_curses,
|
.rstatus = relay_status_curses,
|
||||||
|
.rconnd = relay_connd_curses,
|
||||||
.rerror = relay_error_curses,
|
.rerror = relay_error_curses,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -303,8 +303,45 @@ relay_status_gtk( void* closure, CommsRelayState state )
|
||||||
draw_gtk_status( globals->draw, globals->stateChar );
|
draw_gtk_status( globals->draw, globals->stateChar );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
relay_connd_gtk( void* closure, XP_Bool allHere, XP_U16 nMissing )
|
||||||
|
{
|
||||||
|
XP_Bool skip = XP_FALSE;
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
|
if ( allHere ) {
|
||||||
|
snprintf( buf, sizeof(buf), "All expected players have joined. Play!" );
|
||||||
|
} else {
|
||||||
|
GtkAppGlobals* globals = (GtkAppGlobals*)closure;
|
||||||
|
DeviceRole role = globals->cGlobals.params->serverRole;
|
||||||
|
if ( role == SERVER_ISSERVER ) {
|
||||||
|
snprintf( buf, sizeof(buf), "Connected to relay as host; waiting "
|
||||||
|
"for %d player[s].", nMissing );
|
||||||
|
} else if ( nMissing > 0 ) {
|
||||||
|
snprintf( buf, sizeof(buf), "Connected to relay as guest. Still waiting "
|
||||||
|
"for %d player[s].", nMissing );
|
||||||
|
} else {
|
||||||
|
/* an allHere message should be coming immediately, so no
|
||||||
|
notification now. */
|
||||||
|
skip = XP_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !skip ) {
|
||||||
|
(void)gtkask( buf, GTK_BUTTONS_OK );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
invoke_new_game( gpointer data )
|
invoke_new_game( gpointer data )
|
||||||
|
{
|
||||||
|
GtkAppGlobals* globals = (GtkAppGlobals*)data;
|
||||||
|
new_game_impl( globals, XP_FALSE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
invoke_new_game_conns( gpointer data )
|
||||||
{
|
{
|
||||||
GtkAppGlobals* globals = (GtkAppGlobals*)data;
|
GtkAppGlobals* globals = (GtkAppGlobals*)data;
|
||||||
new_game_impl( globals, XP_TRUE );
|
new_game_impl( globals, XP_TRUE );
|
||||||
|
@ -321,6 +358,9 @@ relay_error_gtk( void* closure, XWREASON relayErr )
|
||||||
switch( relayErr ) {
|
switch( relayErr ) {
|
||||||
case XWRELAY_ERROR_NO_ROOM:
|
case XWRELAY_ERROR_NO_ROOM:
|
||||||
case XWRELAY_ERROR_DUP_ROOM:
|
case XWRELAY_ERROR_DUP_ROOM:
|
||||||
|
proc = invoke_new_game_conns;
|
||||||
|
break;
|
||||||
|
case XWRELAY_ERROR_TOO_MANY:
|
||||||
proc = invoke_new_game;
|
proc = invoke_new_game;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -354,6 +394,7 @@ createOrLoadObjects( GtkAppGlobals* globals )
|
||||||
#endif
|
#endif
|
||||||
#ifdef XWFEATURE_RELAY
|
#ifdef XWFEATURE_RELAY
|
||||||
.rstatus = relay_status_gtk,
|
.rstatus = relay_status_gtk,
|
||||||
|
.rconnd = relay_connd_gtk,
|
||||||
.rerror = relay_error_gtk,
|
.rerror = relay_error_gtk,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -305,6 +305,10 @@ linux_getErrString( UtilErrID id, XP_Bool* silent )
|
||||||
"become a guest, or try again in a few minutes.";
|
"become a guest, or try again in a few minutes.";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ERR_RELAY_BASE + XWRELAY_ERROR_TOO_MANY:
|
||||||
|
message = "You tried to supply more players than the host expected.";
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
XP_LOGF( "no code for error: %d", id );
|
XP_LOGF( "no code for error: %d", id );
|
||||||
message = "<unrecognized error code reported>";
|
message = "<unrecognized error code reported>";
|
||||||
|
|
Loading…
Reference in a new issue