NSM: Give clients a 5 second period in which to announce themselves--otherwise assume they are dumb clients.

This commit is contained in:
Jonathan Moore Liles 2013-04-13 20:17:18 -07:00
parent 5adba898ef
commit 4ef20c0f71
1 changed files with 62 additions and 24 deletions

View File

@ -474,19 +474,6 @@ get_client_by_address ( lo_address addr )
return NULL;
}
bool
replies_still_pending ( )
{
for ( std::list<Client*>::const_iterator i = client.begin();
i != client.end();
++i )
if ( (*i)->active && (*i)->reply_pending() )
return true;
/* if ( (*i)->reply_pending() ) */
/* return true; */
return false;
}
char *
generate_client_id ( Client *c )
@ -502,20 +489,68 @@ generate_client_id ( Client *c )
return strdup(id_str);
}
bool
replies_still_pending ( void )
{
for ( std::list<Client*>::const_iterator i = client.begin();
i != client.end();
++i )
if ( (*i)->active && (*i)->reply_pending() )
return true;
return false;
}
int
number_of_active_clients ( void )
{
int active = 0;
for ( std::list<Client*>::const_iterator i = client.begin(); i != client.end(); i++ )
{
if ( (*i)->active )
active++;
}
return active;
}
void
wait_for_replies ( )
wait_for_announce ( void )
{
fprintf( stdout, "Waiting..." );
fflush(stdout);
MESSAGE( "Waiting for announce messages from clients" );
int n = 7;
int n = 5 * 1000;
while ( n-- )
int active;
while ( n > 0 )
{
printf( "." );
fflush(stdout);
n -= 100;
osc_server->wait( 1000 );
osc_server->wait(100);
active = number_of_active_clients();
if ( client.size() == active )
break;
}
MESSAGE( "Done. %i out of %i clients announced within the initialization grace period", active, client.size() );
}
void
wait_for_replies ( void )
{
MESSAGE( "Waiting for clients to reply to commands" );
int n = 60 * 1000; /* 60 seconds */
while ( n )
{
n -= 100;
osc_server->wait(100);
if ( ! replies_still_pending() )
break;
@ -1229,7 +1264,10 @@ load_session_file ( const char * path )
* messages immediately, even if no replies seem to be pending
* yet. */
// osc_server->wait( 3000 );
/* dumb clients will never send an 'announce message', so we need
* to give up waiting on them fairly soon. */
wait_for_announce();
wait_for_replies();
@ -1735,7 +1773,7 @@ OSC_HANDLER( progress )
{
c->progress = argv[0]->f;
MESSAGE( "%s progress: %i%%", c->name, (int)(c->progress * 100.0f) );
/* MESSAGE( "%s progress: %i%%", c->name, (int)(c->progress * 100.0f) ); */
if ( gui_is_active )
{