Beispiel #1
0
/*
* TV_Disconnect_f
*/
static void TV_Disconnect_f( void )
{
	upstream_t *upstream;

	if( Cmd_Argc() != 2 )
	{
		Com_Printf( "Usage: disconnect <server>\n" );
		return;
	}

	if( !TV_UpstreamForText( Cmd_Argv( 1 ), &upstream ) )
	{
		Com_Printf( "No such upstream\n" );
		return;
	}

	if( !upstream )
	{
		Com_Printf( "Can't disconnect lobby\n" );
		return;
	}

	//	TV_Upstream_Disconnect( upstream, "Disconnected by adminstrator" );
	TV_Upstream_Shutdown( upstream, "Disconnected by adminstrator" );
}
Beispiel #2
0
/*
* TV_GenericConnect_f
*/
static void TV_GenericConnect_f( socket_type_t socket )
{
	netadr_t serveraddress;
	char *servername, *password, *name;
	upstream_t *upstream;
	unsigned int delay;

	if( Cmd_Argc() < 2 )
	{
		Com_Printf( "Usage: %s <server> [password] [name] [delay]\n", Cmd_Argv( 0 ) );
		return;
	}

	if( !NET_StringToAddress( Cmd_Argv( 1 ), &serveraddress ) )
	{
		Com_Printf( "Bad server address: %s\n", Cmd_Argv( 1 ) );
		return;
	}

	servername = TempCopyString( Cmd_Argv( 1 ) );
	password = ( Cmd_Argc() >= 3 ? TempCopyString( Cmd_Argv( 2 ) ) : NULL );
	name = ( Cmd_Argc() >= 4 ? Cmd_Argv( 3 ) : "" );
	delay = ( Cmd_Argc() >= 5 ? (unsigned)atoi( Cmd_Argv( 4 ) )*1000 : RELAY_GLOBAL_DELAY );

	if( TV_UpstreamForText( servername, &upstream ) )
	{
		if( upstream->state >= CA_CONNECTED && upstream->relay.delay == delay
			&& upstream->socket && upstream->socket->type == socket )
		{
			Com_Printf( "Already connected to %s\n", servername );
			goto exit;
		}

		TV_Upstream_Shutdown( upstream, "Disconnected by adminstrator" );
		upstream = NULL;
	}

	upstream = TV_Upstream_New( servername, name, delay );
	assert( upstream );
	TV_Upstream_Connect( upstream, servername, password, socket, &serveraddress );

exit:
	Mem_TempFree( servername );
	if( password )
		Mem_TempFree( password );
}
Beispiel #3
0
/*
* TV_Shutdown
*/
void TV_Shutdown( const char *finalmsg )
{
	int i;

	TV_Downstream_MasterSendQuit();

	for( i = 0; i < tvs.numupstreams; i++ )
	{
		if( !tvs.upstreams[i] )
			continue;

		TV_Upstream_Shutdown( tvs.upstreams[i], "Quit: %s", finalmsg );
	}
	Mem_Free( tvs.upstreams );
	tvs.upstreams = NULL;
	tvs.numupstreams = 0;

	TV_RemoveCommands();
}
Beispiel #4
0
/*
* TV_Demo_f
*/
static void TV_Demo_f( void )
{
	char *servername, *name, *mode;
	upstream_t *upstream;
	unsigned int delay;
	qboolean randomize = qtrue;

	if( Cmd_Argc() < 2 )
	{
		Com_Printf( "Usage: %s <pattern|playlist> [name] [ordered|random] [delay]\n", Cmd_Argv( 0 ) );
		return;
	}

	servername = TempCopyString( Cmd_Argv( 1 ) );
	name = ( Cmd_Argc() >= 3 ? Cmd_Argv( 2 ) : "" );
	mode = ( Cmd_Argc() >= 4 ? Cmd_Argv( 3 ) : "" );
	delay = ( Cmd_Argc() >= 5 ? (unsigned)atoi( Cmd_Argv( 4 ) )*1000 : RELAY_MIN_DELAY );
	if( !Q_stricmp( mode, "ordered" ) )
		randomize = qfalse;

	if( TV_UpstreamForText( servername, &upstream ) )
	{
		if( upstream->state >= CA_CONNECTED && upstream->relay.delay == delay )
		{
			Com_Printf( "Already connected to %s\n", servername );
			goto exit;
		}

		TV_Upstream_Shutdown( upstream, "Disconnected by adminstrator" );
		upstream = NULL;
	}

	upstream = TV_Upstream_New( servername, name, delay );
	assert( upstream );
	TV_Upstream_StartDemo( upstream, servername, randomize );

exit:
	Mem_TempFree( servername );
}