//////////////////////////////////////////////////////////////////////////////
//
// Asura_Platform_NetworkSession_GT2.cpp
//
// PC/PS2 version
//
// Copyright (c) 2004 Rebellion. All rights reserved.
//
// Description:
//
//     ANTS implementations of LAN session code
//
//////////////////////////////////////////////////////////////////////////////

// I N C L U D E S ///////////////////////////////////////////////////////////

#include "Core/Asura.h"

#include "Network/Asura_NetTransport_System.h"
#include "Network/Asura_Network_Session.h"
#ifdef ASURA_PC_SUPPORT_STEAMWORKS
#include "Network/Steamworks/Asura_PC_Steamworks.h"
#endif

#ifdef ASURA_SUPPORT_EXTERNAL_NETWORK

static bool g_bShouldShutdownANTS;
void Asura_Network_Session_System::Platform_Initialise(void)
{
	// currently you can search for LAN games while hosting a game in the lobby.
	// This should only apply to PC when using the placeholder lobby LAN code.
	// Need to prevent ANTS from being initialised twice in this case.
	bool bANTSInitialised = Asura_NetTransport_System::IsInitialised();
	g_bShouldShutdownANTS = !bANTSInitialised;
	if (!bANTSInitialised)
	{
		Asura_NetTransport_System::Initialise();
	}

	#ifdef ASURA_PC_SUPPORT_STEAMWORKS
	if( Asura_PC_Steamworks::IsSteamworksEnabled() )
	{
		Asura_NetTransport_System::StartSessionManager( true );
	}
	else
	#endif
	{
		Asura_NetTransport_System::StartSessionManager();
	}
	
}


void Asura_Network_Session_System::Platform_Shutdown(void)
{
	if (g_bShouldShutdownANTS)
	{
		Asura_NetTransport_System::Shutdown();
	}
	Asura_NetTransport_System::StopSessionManager();
}


void Asura_Network_Session_System::Platform_Update(void)
{
	Asura_NetTransport_System::Update();
	Asura_NetTransport_System::UpdateLANSessions();
}

void Asura_Network_Session::Platform_PrepareConnection(void) const
{
	//This is needed on xbox to setup the secure connection
}

#endif //#ifdef ASURA_SUPPORT_EXTERNAL_NETWORK
